Add method for changing scrollbar visibility

This commit is contained in:
Evan W. Patton
2017-05-23 13:21:51 -04:00
parent 20001aa473
commit 4d22442e1b
2 changed files with 18 additions and 3 deletions

View File

@@ -711,7 +711,9 @@ Blockly.Flyout.prototype.updateDisplay_ = function() {
this.svgGroup_.style.display = show ? 'block' : 'none';
// Update the scrollbar's visiblity too since it should mimic the
// flyout's visibility.
this.scrollbar_.setContainerVisible(show);
if (this.scrollbar_) {
this.scrollbar_.setContainerVisible(show);
}
};
/**
@@ -721,7 +723,9 @@ Blockly.Flyout.prototype.hide = function() {
if (!this.isVisible()) {
return;
}
Blockly.mainWorkspace.scrollbar.setContainerVisible(true);
if (Blockly.mainWorkspace) {
Blockly.mainWorkspace.setScrollbarsVisible(true);
}
this.setVisible(false);
// Delete all the event listeners.
for (var x = 0, listen; listen = this.listeners_[x]; x++) {
@@ -742,7 +746,9 @@ Blockly.Flyout.prototype.hide = function() {
* Variables and procedures have a custom set of blocks.
*/
Blockly.Flyout.prototype.show = function(xmlList) {
Blockly.mainWorkspace.scrollbar.setContainerVisible(false); // hide parent's scrollbars
if (Blockly.mainWorkspace) {
Blockly.mainWorkspace.setScrollbarsVisible(false); // hide parent's scrollbars
}
this.workspace_.setResizesEnabled(false);
this.hide();
this.clearOldBlocks_();

View File

@@ -1671,6 +1671,15 @@ Blockly.WorkspaceSvg.prototype.getButtonCallback = function(key) {
return this.flyoutButtonCallbacks_[key];
};
/**
* Convenience method to hide the scrollbars on the workspace. This method has
* no effect if the workspace's options had scrollbars set to false.
* @param {boolean} visible true to show the scrollbars, otherwise false.
*/
Blockly.WorkspaceSvg.prototype.setScrollbarsVisible = function(visible) {
this.scrollbar && this.scrollbar.setContainerVisible(visible)
};
// Export symbols that would otherwise be renamed by Closure compiler.
Blockly.WorkspaceSvg.prototype['setVisible'] =
Blockly.WorkspaceSvg.prototype.setVisible;