Fix regression with maintenance of scroll position when jumping between discussion list filters

This commit is contained in:
Toby Zerner 2016-03-18 09:36:09 +10:30
parent cd6e6addf7
commit cf63e063ba

View File

@ -98,8 +98,9 @@ export default class IndexPage extends Page {
// Work out the difference between the height of this hero and that of the
// previous hero. Maintain the same scroll position relative to the bottom
// of the hero so that the 'fixed' sidebar doesn't jump around.
const heroHeight = this.$('.Hero').outerHeight();
// of the hero so that the sidebar doesn't jump around.
const oldHeroHeight = app.cache.heroHeight;
const heroHeight = app.cache.heroHeight = this.$('.Hero').outerHeight();
const scrollTop = app.cache.scrollTop;
$('#app').css('min-height', $(window).height() + heroHeight);
@ -107,9 +108,9 @@ export default class IndexPage extends Page {
// Scroll to the remembered position. We do this after a short delay so that
// it happens after the browser has done its own "back button" scrolling,
// which isn't right. https://github.com/flarum/core/issues/835
setTimeout(() => $(window).scrollTop(scrollTop - app.cache.heroHeight + heroHeight), 1);
app.cache.heroHeight = heroHeight;
const scroll = () => $(window).scrollTop(scrollTop - oldHeroHeight + heroHeight);
scroll();
setTimeout(scroll, 1);
// If we've just returned from a discussion page, then the constructor will
// have set the `lastDiscussion` property. If this is the case, we want to