mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Fix janky scrolling in vertical case
This commit is contained in:
@@ -416,10 +416,12 @@ Blockly.getMainWorkspaceMetrics_ = function() {
|
||||
var svgSize = Blockly.svgSize(this.getParentSvg());
|
||||
if (this.toolbox_) {
|
||||
// If the toolbox is at the bottom it's laid out separately from the main
|
||||
// workspace, rather than overlapping.
|
||||
// workspace, rather than overlapping, so we don't need to take its size
|
||||
// into account.
|
||||
if (this.toolboxPosition == Blockly.TOOLBOX_AT_TOP) {
|
||||
svgSize.height -= this.toolbox_.getHeight();
|
||||
} else {
|
||||
} else if (this.toolboxPosition == Blockly.TOOLBOX_AT_LEFT ||
|
||||
this.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT) {
|
||||
svgSize.width -= this.toolbox_.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ Blockly.Flyout.prototype.getMetrics_ = function() {
|
||||
viewTop: -this.workspace_.scrollY,
|
||||
viewLeft: -this.workspace_.scrollX,
|
||||
contentTop: optionBox.y,
|
||||
contentLeft: 0,
|
||||
contentLeft: optionBox.x,
|
||||
absoluteTop: absoluteTop,
|
||||
absoluteLeft: absoluteLeft
|
||||
};
|
||||
@@ -308,11 +308,9 @@ Blockly.Flyout.prototype.setMetrics_ = function(xyRatio) {
|
||||
return;
|
||||
}
|
||||
if (!this.horizontalLayout_ && goog.isNumber(xyRatio.y)) {
|
||||
this.workspace_.scrollY =
|
||||
-metrics.contentHeight * xyRatio.y - metrics.contentTop;
|
||||
this.workspace_.scrollY = -metrics.contentHeight * xyRatio.y;
|
||||
} else if (this.horizontalLayout_ && goog.isNumber(xyRatio.x)) {
|
||||
this.workspace_.scrollX =
|
||||
-metrics.contentWidth * xyRatio.x - metrics.contentLeft;
|
||||
this.workspace_.scrollX = -metrics.contentWidth * xyRatio.x;
|
||||
}
|
||||
|
||||
this.workspace_.translate(this.workspace_.scrollX + metrics.absoluteLeft,
|
||||
@@ -671,36 +669,6 @@ Blockly.Flyout.prototype.clearOldBlocks_ = function() {
|
||||
this.buttons_.length = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add listeners to a block that has been added to the flyout.
|
||||
* @param {!Element} root The root node of the SVG group the block is in.
|
||||
* @param {!Blockly.Block} block The block to add listeners for.
|
||||
* @param {!Element} rect The invisible rectangle under the block that acts as
|
||||
* a button for that block.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.addBlockListeners_ = function(root, block, rect) {
|
||||
if (this.autoClose) {
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mousedown', null,
|
||||
this.createBlockFunc_(block)));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mousedown', null,
|
||||
this.createBlockFunc_(block)));
|
||||
} else {
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mousedown', null,
|
||||
this.blockMouseDown_(block)));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mousedown', null,
|
||||
this.blockMouseDown_(block)));
|
||||
}
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mouseover', block,
|
||||
block.addSelect));
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mouseout', block,
|
||||
block.removeSelect));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mouseover', block,
|
||||
block.addSelect));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mouseout', block,
|
||||
block.removeSelect));
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete blocks and background buttons from a previous showing of the flyout.
|
||||
* @private
|
||||
@@ -835,7 +803,6 @@ Blockly.Flyout.prototype.onMouseMove_ = function(e) {
|
||||
this.startDragMouseX_ = e.clientX;
|
||||
var x = metrics.viewLeft - dx;
|
||||
x = goog.math.clamp(x, 0, metrics.contentWidth - metrics.viewWidth);
|
||||
this.scrollbar_.set(metrics.contentLeft - x);
|
||||
this.scrollbar_.set(x);
|
||||
} else {
|
||||
if (metrics.contentHeight - metrics.viewHeight < 0) {
|
||||
|
||||
Reference in New Issue
Block a user