Make composer sliding animation less jumpy when replying

This commit is contained in:
Toby Zerner 2015-06-08 09:47:28 +09:30
parent 4a2d0ad76e
commit 7ea3252776
2 changed files with 8 additions and 11 deletions

View File

@ -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,19 +182,14 @@ 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());
}
}
}
// Update the height of the stuff inside of the composer. There should be
// an element with the class .flexible-height — this element is intended

View File

@ -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) {