Prevent category menu jump on sprite switch

This commit is contained in:
Eric Rosenbaum committed 2018-04-27 10:00:22 -04:00
1 parent e0056a914f
commit bad3e8a49e
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;