mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Move scroll animation into flyout_base
This commit is contained in:
parent
53101f763f
commit
e494993e82
3 changed files with 23 additions and 38 deletions
|
@ -544,6 +544,27 @@ Blockly.Flyout.prototype.recordCategoryScrollPositions_ = function() {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Step the scrolling animation by scrolling a fraction of the way to
|
||||
* a scroll target, and request the next frame if necessary.
|
||||
*/
|
||||
Blockly.Flyout.prototype.stepScrollAnimation = function() {
|
||||
if (!this.scrollTarget) {
|
||||
return;
|
||||
}
|
||||
var scrollPos = this.horizontalLayout_ ?
|
||||
-this.workspace_.scrollX : -this.workspace_.scrollY;
|
||||
var diff = this.scrollTarget - scrollPos;
|
||||
if (Math.abs(diff) < 1) {
|
||||
this.scrollbar_.set(this.scrollTarget);
|
||||
return;
|
||||
}
|
||||
this.scrollbar_.set(scrollPos + diff * 0.3);
|
||||
|
||||
// Polyfilled by goog.dom.animationFrame.polyfill
|
||||
requestAnimationFrame(this.stepScrollAnimation.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete blocks and background buttons from a previous showing of the flyout.
|
||||
* @private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue