FIX: Scroll jumping in some dimensions of browser

This commit is contained in:
Robin Ward 2016-06-10 14:14:08 -04:00
parent 9ecd5bd599
commit a77f5a75a1
2 changed files with 10 additions and 8 deletions

View File

@ -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 }));

View File

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