Commit 244a3cce authored by Neil Fraser's avatar Neil Fraser

Allow scrollbars without categories.

parent ad7d0a13
This diff is collapsed.
...@@ -117,14 +117,9 @@ Blockly.parseOptions_ = function(options) { ...@@ -117,14 +117,9 @@ Blockly.parseOptions_ = function(options) {
hasDisable = hasCategories; hasDisable = hasCategories;
} }
} }
if (tree && !hasCategories) { var hasScrollbars = options['scrollbars'];
// Scrollbars are not compatible with a non-flyout toolbox. if (hasScrollbars === undefined) {
var hasScrollbars = false; hasScrollbars = hasCategories;
} else {
var hasScrollbars = options['scrollbars'];
if (hasScrollbars === undefined) {
hasScrollbars = true;
}
} }
var hasSounds = options['sounds']; var hasSounds = options['sounds'];
if (hasSounds === undefined) { if (hasSounds === undefined) {
...@@ -287,42 +282,44 @@ Blockly.createDom_ = function(container) { ...@@ -287,42 +282,44 @@ Blockly.createDom_ = function(container) {
flyout.autoClose = false; flyout.autoClose = false;
// Insert the flyout behind the workspace so that blocks appear on top. // Insert the flyout behind the workspace so that blocks appear on top.
goog.dom.insertSiblingBefore(flyoutSvg, Blockly.mainWorkspace.svgGroup_); goog.dom.insertSiblingBefore(flyoutSvg, Blockly.mainWorkspace.svgGroup_);
}
if (!Blockly.hasScrollbars) {
var workspaceChanged = function() { var workspaceChanged = function() {
if (Blockly.Block.dragMode_ == 0) { if (Blockly.Block.dragMode_ == 0) {
var metrics = Blockly.mainWorkspace.getMetrics(); var metrics = Blockly.mainWorkspace.getMetrics();
if (metrics.contentTop < 0 || var edgeLeft = metrics.viewLeft + metrics.absoluteLeft;
var edgeTop = metrics.viewTop + metrics.absoluteTop;
if (metrics.contentTop < edgeTop ||
metrics.contentTop + metrics.contentHeight > metrics.contentTop + metrics.contentHeight >
metrics.viewHeight + metrics.viewTop || metrics.viewHeight + edgeTop ||
metrics.contentLeft < (Blockly.RTL ? metrics.viewLeft : 0) || metrics.contentLeft <
(Blockly.RTL ? metrics.viewLeft : edgeLeft) ||
metrics.contentLeft + metrics.contentWidth > (Blockly.RTL ? metrics.contentLeft + metrics.contentWidth > (Blockly.RTL ?
metrics.viewWidth : metrics.viewWidth : metrics.viewWidth + edgeLeft)) {
metrics.viewWidth + metrics.viewLeft)) { // One or more blocks may be out of bounds. Bump them back in.
// One or more blocks is out of bounds. Bump them back in.
var MARGIN = 25; var MARGIN = 25;
var blocks = Blockly.mainWorkspace.getTopBlocks(false); var blocks = Blockly.mainWorkspace.getTopBlocks(false);
for (var b = 0, block; block = blocks[b]; b++) { for (var b = 0, block; block = blocks[b]; b++) {
var blockXY = block.getRelativeToSurfaceXY(); var blockXY = block.getRelativeToSurfaceXY();
var blockHW = block.getHeightWidth(); var blockHW = block.getHeightWidth();
// Bump any block that's above the top back inside. // Bump any block that's above the top back inside.
var overflow = metrics.viewTop + MARGIN - blockHW.height - var overflow = edgeTop + MARGIN - blockHW.height - blockXY.y;
blockXY.y;
if (overflow > 0) { if (overflow > 0) {
block.moveBy(0, overflow); block.moveBy(0, overflow);
} }
// Bump any block that's below the bottom back inside. // Bump any block that's below the bottom back inside.
var overflow = metrics.viewTop + metrics.viewHeight - MARGIN - var overflow = edgeTop + metrics.viewHeight - MARGIN - blockXY.y;
blockXY.y;
if (overflow < 0) { if (overflow < 0) {
block.moveBy(0, overflow); block.moveBy(0, overflow);
} }
// Bump any block that's off the left back inside. // Bump any block that's off the left back inside.
var overflow = MARGIN + metrics.viewLeft - blockXY.x - var overflow = MARGIN + edgeLeft -
(Blockly.RTL ? 0 : blockHW.width); blockXY.x - (Blockly.RTL ? 0 : blockHW.width);
if (overflow > 0) { if (overflow > 0) {
block.moveBy(overflow, 0); block.moveBy(overflow, 0);
} }
// Bump any block that's off the right back inside. // Bump any block that's off the right back inside.
var overflow = metrics.viewLeft + metrics.viewWidth - MARGIN - var overflow = edgeLeft + metrics.viewWidth - MARGIN -
blockXY.x + (Blockly.RTL ? blockHW.width : 0); blockXY.x + (Blockly.RTL ? blockHW.width : 0);
if (overflow < 0) { if (overflow < 0) {
block.moveBy(overflow, 0); block.moveBy(overflow, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment