Maintain scroll position relative to bottom of hero when switching categories

This commit is contained in:
Toby Zerner 2015-05-21 08:15:58 +09:30
parent 8f7e563036
commit c95b8838ac

View File

@ -129,8 +129,14 @@ export default class IndexPage extends Component {
$('body').removeClass('index-page'); $('body').removeClass('index-page');
} }
var heroHeight = this.$('.hero').css('height', '').outerHeight();
var scrollTop = app.cache.scrollTop; var scrollTop = app.cache.scrollTop;
$(window).scrollTop(scrollTop);
$('.global-page').css('min-height', $(window).height() + heroHeight);
$(window).scrollTop(scrollTop - (app.cache.heroHeight - heroHeight));
app.cache.heroHeight = heroHeight;
if (this.lastDiscussion) { if (this.lastDiscussion) {
var $discussion = this.$('.discussion-summary[data-id='+this.lastDiscussion.id()+']'); var $discussion = this.$('.discussion-summary[data-id='+this.lastDiscussion.id()+']');