mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Make sure selected discussion is visible in pane
This commit is contained in:
parent
a5be161d61
commit
8d95e21d6e
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue
Block a user