1
0
mirror of https://github.com/flarum/core.git synced 2025-01-18 06:38:25 +01:00

Make sure selected discussion is visible in pane

This commit is contained in:
Toby Zerner 2015-02-06 10:36:16 +10:30
parent 809a87f03f
commit cab17be53a

View File

@ -19,7 +19,7 @@ export default Ember.View.extend({
// Affix the sidebar so that when the user scrolls down it will stick
// to the top of their viewport.
var $sidebar = this.$().find('.index-nav');
var $sidebar = this.$('.index-nav');
$sidebar.find('> ul').affix({
offset: {
top: function () {
@ -47,13 +47,28 @@ export default Ember.View.extend({
if (e.pageX < 10) {
controller.send('showPane');
}
});
});
},
willDestroyElement: function() {
$(document).off('mousemove.showPane');
},
scrollToDiscussion: function() {
var view = this;
Ember.run.scheduleOnce('afterRender', function() {
var $index = view.$('.index-area');
var $discussion = $index.find('.discussion-summary.active');
if ($discussion.length) {
var indexTop = $index.offset().top;
var discussionTop = $discussion.offset().top;
if (discussionTop < indexTop || discussionTop + $discussion.outerHeight() > indexTop + $index.outerHeight()) {
$index.scrollTop($index.scrollTop() - indexTop + discussionTop);
}
}
});
}.observes('controller.controllers.discussion.model'),
populateSidebarDefault: function(sidebar) {
var newDiscussion = ActionButton.create({
label: 'Start a Discussion',