banktags: Don't lose scroll position when hiding separators

This commit is contained in:
Jordan Atwood
2020-09-07 00:40:24 -07:00
parent 00fc1314f7
commit a6628564f8

View File

@@ -555,16 +555,18 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
}
}
int itemContainerHeight = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER).getHeight();
final Widget bankItemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
int itemContainerHeight = bankItemContainer.getHeight();
// add a second row of height here to allow users to scroll down when the last row is partially visible
int adjustedScrollHeight = (items / ITEMS_PER_ROW) * ITEM_VERTICAL_SPACING + ITEM_VERTICAL_SPACING;
itemContainer.setScrollHeight(Math.max(adjustedScrollHeight, itemContainerHeight));
final int itemContainerScroll = bankItemContainer.getScrollY();
clientThread.invokeLater(() ->
client.runScript(ScriptID.UPDATE_SCROLLBAR,
WidgetInfo.BANK_SCROLLBAR.getId(),
WidgetInfo.BANK_ITEM_CONTAINER.getId(),
0));
itemContainerScroll));
}