Merge pull request #1883 from ericrosenbaum/bugfix/scroll-position-stability-2

Prevent category menu jump on sprite switch
This commit is contained in:
Eric Rosenbaum authored and GitHub committed 2018-04-30 10:28:22 -04:00
commit fe7b35cd27
1 file changed
+6 -1
+6 -1
View File
@@ -99,7 +99,12 @@ class Blocks extends React.Component {
const offset = this.workspace.toolbox_.getCategoryScrollOffset();
this.workspace.updateToolbox(this.props.toolboxXML);
const currentCategoryPos = this.workspace.toolbox_.getCategoryPositionByName(categoryName);
this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos + offset);
const currentCategoryLen = this.workspace.toolbox_.getCategoryLengthByName(categoryName);
if (offset < currentCategoryLen) {
this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos + offset);
} else {
this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos);
}
}
if (this.props.isVisible === prevProps.isVisible) {
return;