From 7ea3252776f7ebc251762880be01ce4575a9e096 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 8 Jun 2015 09:47:28 +0930 Subject: [PATCH] Make composer sliding animation less jumpy when replying --- .../core/js/forum/src/components/composer.js | 15 +++++---------- .../js/forum/src/initializers/state-helpers.js | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/framework/core/js/forum/src/components/composer.js b/framework/core/js/forum/src/components/composer.js index 5534ba263..fbd2aa8c9 100644 --- a/framework/core/js/forum/src/components/composer.js +++ b/framework/core/js/forum/src/components/composer.js @@ -117,7 +117,7 @@ class Composer extends Component { this.updateHeight(); var scrollTop = $(window).scrollTop(); - this.updateBodyPadding(false, scrollTop > 0 && scrollTop + $(window).height() >= $(document).height()); + this.updateBodyPadding(scrollTop > 0 && scrollTop + $(window).height() >= $(document).height()); localStorage.setItem('composerHeight', height); } @@ -167,7 +167,7 @@ class Composer extends Component { } if (this.position() !== Composer.PositionEnum.FULLSCREEN) { - this.updateBodyPadding(true, anchorToBottom); + this.updateBodyPadding(anchorToBottom); } else { this.component.focus(); } @@ -182,17 +182,12 @@ class Composer extends Component { // Update the amount of padding-bottom on the body so that the page's // content will still be visible above the composer when the page is // scrolled right to the bottom. - updateBodyPadding(animate, anchorToBottom) { - var func = animate ? 'animate' : 'css'; + updateBodyPadding(anchorToBottom) { var paddingBottom = this.position() !== Composer.PositionEnum.HIDDEN ? this.computedHeight() - parseInt($('#page').css('padding-bottom')) : 0; - $('#content')[func]({paddingBottom}, 'fast'); + $('#content').css({paddingBottom}); if (anchorToBottom) { - if (animate) { - $('html, body').stop(true).animate({scrollTop: $(document).height()}, 'fast'); - } else { - $('html, body').scrollTop($(document).height()); - } + $('html, body').scrollTop($(document).height()); } } diff --git a/framework/core/js/forum/src/initializers/state-helpers.js b/framework/core/js/forum/src/initializers/state-helpers.js index 3363a6ff6..643b86a06 100644 --- a/framework/core/js/forum/src/initializers/state-helpers.js +++ b/framework/core/js/forum/src/initializers/state-helpers.js @@ -1,10 +1,12 @@ +import Composer from 'flarum/components/composer'; import ReplyComposer from 'flarum/components/reply-composer'; import DiscussionPage from 'flarum/components/discussion-page'; export default function(app) { app.composingReplyTo = function(discussion) { return this.composer.component instanceof ReplyComposer && - this.composer.component.props.discussion === discussion; + this.composer.component.props.discussion === discussion && + this.composer.position() !== Composer.PositionEnum.HIDDEN; }; app.viewingDiscussion = function(discussion) {