From 7295cffd3234d5e481c3d21d3b575e381ad5cb44 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 15 Jun 2015 12:17:19 +0930 Subject: [PATCH] Maintain scroll position when hiding the composer --- .../core/js/forum/src/components/composer.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/framework/core/js/forum/src/components/composer.js b/framework/core/js/forum/src/components/composer.js index 720c24d6e..9398c6b59 100644 --- a/framework/core/js/forum/src/components/composer.js +++ b/framework/core/js/forum/src/components/composer.js @@ -136,9 +136,9 @@ class Composer extends Component { var $composer = this.$().stop(true); var oldHeight = $composer.is(':visible') ? $composer.outerHeight() : 0; - if (this.position() !== Composer.PositionEnum.HIDDEN) { - m.redraw(true); - } + var scrollTop = $(window).scrollTop(); + + m.redraw(true); this.$().height(this.computedHeight()); var newHeight = $composer.outerHeight(); @@ -167,7 +167,8 @@ class Composer extends Component { } if (this.position() !== Composer.PositionEnum.FULLSCREEN) { - this.updateBodyPadding(anchorToBottom); + this.updateBodyPadding(); + $('html, body').scrollTop(anchorToBottom ? $(document).height() : scrollTop); } else { this.component.focus(); } @@ -182,15 +183,11 @@ 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(anchorToBottom) { + updateBodyPadding() { var paddingBottom = this.position() !== Composer.PositionEnum.HIDDEN && this.position() !== Composer.PositionEnum.MINIMIZED ? this.computedHeight() - parseInt($('#page').css('padding-bottom')) : 0; $('#content').css({paddingBottom}); - - if (anchorToBottom) { - $('html, body').scrollTop($(document).height()); - } } // Update the height of the stuff inside of the composer. There should be