diff --git a/HISTORY.md b/HISTORY.md index 675dbe90..8cef5793 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -18,6 +18,7 @@ * gui, object, store, etc.: unified blocks palette option, thanks, Michael! * merged scenes branch * morphic: fixed centering of menus, thanks, Brian Broll! +* gui: animate scrollToPaletteCategory() ### 2021-05-21 * gui, scenes, store: proxied thumbnail, name and notes in project, restored in XML diff --git a/src/gui.js b/src/gui.js index 4e1a0f28..5a8b3d67 100644 --- a/src/gui.js +++ b/src/gui.js @@ -2532,13 +2532,25 @@ IDE_Morph.prototype.refreshPalette = function (shouldIgnorePosition) { }; IDE_Morph.prototype.scrollPaletteToCategory = function (category) { - let palette = this.palette, + var palette = this.palette, firstInCategory = palette.contents.children.find( block => block.category === category - ); + ), + delta = palette.top() - firstInCategory.top() + palette.padding, + msecs = this.isAnimating ? 100 : 0; - palette.scrollY(palette.top() - firstInCategory.top() + palette.padding); - palette.adjustScrollBars(); + this.world().animations.push(new Animation( + y => { // setter + palette.contents.setTop(y); + palette.contents.keepInScrollFrame(); + palette.adjustScrollBars(); + }, + () => palette.contents.top(), // getter + delta, // delta + msecs, // duration in ms + 'cubic_in', // easing + null // onComplete + )); }; IDE_Morph.prototype.pressStart = function () {