mirror of
https://github.com/flarum/framework.git
synced 2025-02-16 22:52:45 +08:00
Make discussion in view when returning to index
This commit is contained in:
parent
3d6d3192d9
commit
d5bd462ed9
|
@ -30,6 +30,7 @@ export default Ember.Route.extend({
|
|||
|
||||
setupController: function(controller, discussion) {
|
||||
controller.set('model', discussion);
|
||||
this.controllerFor('index/index').set('lastDiscussion', discussion);
|
||||
|
||||
// Set up the post stream object. It needs to know about the discussion
|
||||
// it's representing the posts for, and we also need to inject the Ember
|
||||
|
|
|
@ -4,7 +4,20 @@ export default Ember.View.extend({
|
|||
|
||||
didInsertElement: function() {
|
||||
this.updateTitle();
|
||||
$(window).scrollTop(this.get('controller.scrollTop'));
|
||||
var scrollTop = this.get('controller.scrollTop');
|
||||
$(window).scrollTop(scrollTop);
|
||||
|
||||
var lastDiscussion = this.get('controller.lastDiscussion');
|
||||
if (lastDiscussion) {
|
||||
var $discussion = $('.index-area .discussion-summary[data-id='+lastDiscussion.get('id')+']');
|
||||
if ($discussion.length) {
|
||||
var indexTop = $('#header').outerHeight();
|
||||
var discussionTop = $discussion.offset().top;
|
||||
if (discussionTop < scrollTop + indexTop || discussionTop + $discussion.outerHeight() > scrollTop + $(window).height()) {
|
||||
$(window).scrollTop(discussionTop - indexTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement: function() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user