From a77f5a75a1b8548b6c9b83afa67ab3aa3c6a70a1 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 10 Jun 2016 14:14:08 -0400 Subject: [PATCH] FIX: Scroll jumping in some dimensions of browser --- .../discourse/widgets/post-stream.js.es6 | 16 +++++++++------- .../javascripts/discourse/widgets/post.js.es6 | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/post-stream.js.es6 b/app/assets/javascripts/discourse/widgets/post-stream.js.es6 index 704b671f246..9488cf7686a 100644 --- a/app/assets/javascripts/discourse/widgets/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-stream.js.es6 @@ -8,6 +8,7 @@ const DAY = 1000 * 60 * 60 * 24; const _dontCloak = {}; let _cloaked = {}; +let _heights = {}; export function preventCloak(postId) { _dontCloak[postId] = true; @@ -17,7 +18,8 @@ export function cloak(post, component) { if (!CLOAKING_ENABLED || _cloaked[post.id] || _dontCloak[post.id]) { return; } const $post = $(`#post_${post.post_number}`); - _cloaked[post.id] = $post.outerHeight(); + _cloaked[post.id] = true; + _heights[post.id] = $post.outerHeight(); Ember.run.debounce(component, 'queueRerender', 1000); } @@ -27,7 +29,10 @@ export function uncloak(post, component) { component.queueRerender(); } -addWidgetCleanCallback('post-stream', () => _cloaked = {}); +addWidgetCleanCallback('post-stream', () => { + _cloaked = {}; + _heights = {}; +}); export default createWidget('post-stream', { tagName: 'div.post-stream', @@ -88,11 +93,8 @@ export default createWidget('post-stream', { } prevDate = curTime; - const height = _cloaked[post.id]; - if (height) { - transformed.cloaked = true; - transformed.height = height; - } + transformed.height = _heights[post.id]; + transformed.cloaked = _cloaked[post.id]; if (transformed.isSmallAction) { result.push(this.attach('post-small-action', transformed, { model: post })); diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6 index 506e9dab7b7..2ba179a9e80 100644 --- a/app/assets/javascripts/discourse/widgets/post.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post.js.es6 @@ -384,7 +384,7 @@ export default createWidget('post', { shadowTree: true, buildAttributes(attrs) { - return attrs.cloaked ? { style: `height: ${attrs.height}px` } : undefined; + return attrs.height ? { style: `height: ${attrs.height}px` } : undefined; }, buildId(attrs) {