Fixed flyout scrollbars not being updated when the flyout was dragged.

This commit is contained in:
Beka Westberg
2019-07-29 13:39:06 -07:00
parent 44e559c4d9
commit b45492c4b3

View File

@@ -62,19 +62,24 @@ Blockly.FlyoutDragger = function(flyout) {
goog.inherits(Blockly.FlyoutDragger, Blockly.WorkspaceDragger);
/**
* Move the appropriate scrollbar to drag the flyout.
* Since flyouts only scroll in one direction at a time, this will discard one
* of the calculated values.
* x and y are in pixels.
* @param {number} x The new x position to move the scrollbar to.
* @param {number} y The new y position to move the scrollbar to.
* @private
* Move the flyout based on the most recent mouse movements.
* @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has
* moved from the position at the start of the drag, in pixel coordinates.
* @package
*/
Blockly.FlyoutDragger.prototype.updateScroll_ = function(x, y) {
// Move the scrollbar and the flyout will scroll automatically.
Blockly.FlyoutDragger.prototype.drag = function(currentDragDeltaXY) {
// startScrollXY_ is assigned by the superclass.
var newXY = Blockly.utils.Coordinate.sum(this.startScrollXY_, currentDragDeltaXY);
// We can't call workspace.scroll because the flyout's workspace doesn't own
// it's own scrollbars. This is because (as of 2.20190722.1) the
// workspace's scrollbar property must be a scrollbar pair, rather than a
// single scrollbar.
// Instead we'll just expect setting the scrollbar to update the scroll of
// the workspace as well.
if (this.horizontalLayout_) {
this.scrollbar_.set(x);
this.scrollbar_.set(-newXY.x);
} else {
this.scrollbar_.set(y);
this.scrollbar_.set(-newXY.y);
}
};