1
0
mirror of https://github.com/flarum/core.git synced 2025-07-27 03:30:28 +02:00

Make composer sliding animation less jumpy when replying

This commit is contained in:
Toby Zerner
2015-06-08 09:47:28 +09:30
parent 7a76bf175d
commit 250e16d970
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,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());
}
}