mirror of
https://github.com/flarum/core.git
synced 2025-07-20 00:01:17 +02:00
Make sure selected discussion is visible in pane
This commit is contained in:
@@ -19,7 +19,7 @@ export default Ember.View.extend({
|
|||||||
|
|
||||||
// Affix the sidebar so that when the user scrolls down it will stick
|
// Affix the sidebar so that when the user scrolls down it will stick
|
||||||
// to the top of their viewport.
|
// to the top of their viewport.
|
||||||
var $sidebar = this.$().find('.index-nav');
|
var $sidebar = this.$('.index-nav');
|
||||||
$sidebar.find('> ul').affix({
|
$sidebar.find('> ul').affix({
|
||||||
offset: {
|
offset: {
|
||||||
top: function () {
|
top: function () {
|
||||||
@@ -54,6 +54,21 @@ export default Ember.View.extend({
|
|||||||
$(document).off('mousemove.showPane');
|
$(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) {
|
populateSidebarDefault: function(sidebar) {
|
||||||
var newDiscussion = ActionButton.create({
|
var newDiscussion = ActionButton.create({
|
||||||
label: 'Start a Discussion',
|
label: 'Start a Discussion',
|
||||||
|
Reference in New Issue
Block a user