mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 05:55:58 +08:00
Make composer sliding animation less jumpy when replying
This commit is contained in:
parent
4a2d0ad76e
commit
7ea3252776
|
@ -117,7 +117,7 @@ class Composer extends Component {
|
||||||
this.updateHeight();
|
this.updateHeight();
|
||||||
|
|
||||||
var scrollTop = $(window).scrollTop();
|
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);
|
localStorage.setItem('composerHeight', height);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ class Composer extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.position() !== Composer.PositionEnum.FULLSCREEN) {
|
if (this.position() !== Composer.PositionEnum.FULLSCREEN) {
|
||||||
this.updateBodyPadding(true, anchorToBottom);
|
this.updateBodyPadding(anchorToBottom);
|
||||||
} else {
|
} else {
|
||||||
this.component.focus();
|
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
|
// 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
|
// content will still be visible above the composer when the page is
|
||||||
// scrolled right to the bottom.
|
// scrolled right to the bottom.
|
||||||
updateBodyPadding(animate, anchorToBottom) {
|
updateBodyPadding(anchorToBottom) {
|
||||||
var func = animate ? 'animate' : 'css';
|
|
||||||
var paddingBottom = this.position() !== Composer.PositionEnum.HIDDEN ? this.computedHeight() - parseInt($('#page').css('padding-bottom')) : 0;
|
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 (anchorToBottom) {
|
||||||
if (animate) {
|
|
||||||
$('html, body').stop(true).animate({scrollTop: $(document).height()}, 'fast');
|
|
||||||
} else {
|
|
||||||
$('html, body').scrollTop($(document).height());
|
$('html, body').scrollTop($(document).height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Update the height of the stuff inside of the composer. There should be
|
// Update the height of the stuff inside of the composer. There should be
|
||||||
// an element with the class .flexible-height — this element is intended
|
// an element with the class .flexible-height — this element is intended
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
import Composer from 'flarum/components/composer';
|
||||||
import ReplyComposer from 'flarum/components/reply-composer';
|
import ReplyComposer from 'flarum/components/reply-composer';
|
||||||
import DiscussionPage from 'flarum/components/discussion-page';
|
import DiscussionPage from 'flarum/components/discussion-page';
|
||||||
|
|
||||||
export default function(app) {
|
export default function(app) {
|
||||||
app.composingReplyTo = function(discussion) {
|
app.composingReplyTo = function(discussion) {
|
||||||
return this.composer.component instanceof ReplyComposer &&
|
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) {
|
app.viewingDiscussion = function(discussion) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user