mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
feat: add the ability to toggle scrollbar visibility (#7314)
This commit is contained in:
@@ -657,13 +657,25 @@ export class Scrollbar {
|
||||
* @param visible True if visible.
|
||||
*/
|
||||
setVisible(visible: boolean) {
|
||||
const visibilityChanged = visible !== this.isVisible();
|
||||
|
||||
// Ideally this would also apply to scrollbar pairs, but that's a bigger
|
||||
// headache (due to interactions with the corner square).
|
||||
// headache (due to interactions with the corner square), and the fact
|
||||
// that telling the pair to resize itself would cause circular dependencies.
|
||||
if (this.pair) {
|
||||
throw Error('Unable to toggle visibility of paired scrollbars.');
|
||||
}
|
||||
this.setVisibleInternal(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the scrollbar is visible. Bypasses checking whether this
|
||||
* scrollbar is part of a pair so that it can be toggled by the scrollbar
|
||||
* pair.
|
||||
*
|
||||
* @param visible True if visible.
|
||||
* @internal
|
||||
*/
|
||||
setVisibleInternal(visible: boolean) {
|
||||
const visibilityChanged = visible !== this.isVisible();
|
||||
this.isHandleVisible = visible;
|
||||
if (visibilityChanged) {
|
||||
this.updateDisplay_();
|
||||
|
||||
@@ -306,6 +306,16 @@ export class ScrollbarPair {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visibility of any existing scrollbars.
|
||||
*
|
||||
* @param visible True if visible.
|
||||
*/
|
||||
setVisible(visible: boolean) {
|
||||
if (this.hScroll) this.hScroll.setVisibleInternal(visible);
|
||||
if (this.vScroll) this.vScroll.setVisibleInternal(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the scrollbars' locations within their path and length.
|
||||
* This should be called when the contents of the workspace have changed.
|
||||
|
||||
Reference in New Issue
Block a user