From 9c7bef8e01229f27143f67887cd35a2ab0b5ab6d Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 8 May 2016 09:59:29 +0100 Subject: [PATCH] Add workaround for inaccurate scroll to top Fixes #560 by calling the scroll method twice. It's a hack, but it seems to work, and can be removed once the underlying iron-list bug is fixed. --- src/gui/html/js/events.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/html/js/events.js b/src/gui/html/js/events.js index d7fe3a51..7684b933 100644 --- a/src/gui/html/js/events.js +++ b/src/gui/html/js/events.js @@ -8,10 +8,15 @@ function onSidebarFilterToggle(evt) { } filterPluginData(loot.game.plugins, loot.filters); } - +function secondScrollToTop() { + document.getElementById('pluginCardList').scroll(0, 0); + document.getElementById('main').removeEventListener('scroll', secondScrollToTop); +} function onJumpToGeneralInfo() { - window.location.hash = ''; - document.getElementById('main').scrollTop = 0; + /* PolymerElements/iron-list#240 means a second call is necessary to complete + the scroll. This is a hack until the bug gets fixed. */ + document.getElementById('main').addEventListener('scroll', secondScrollToTop); + document.getElementById('pluginCardList').scroll(0, 0); } function onChangeGame(evt) { if (evt.detail.item.getAttribute('value') === loot.game.folder) {