From 8c41195223a6e8e0a5accb8646bc7cb500ba745b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 18 May 2015 10:32:46 +0930 Subject: [PATCH] Reposition the post mention preview after its content has loaded --- extensions/mentions/js/src/post-mention-previews.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/mentions/js/src/post-mention-previews.js b/extensions/mentions/js/src/post-mention-previews.js index 3930a67e9..995554226 100644 --- a/extensions/mentions/js/src/post-mention-previews.js +++ b/extensions/mentions/js/src/post-mention-previews.js @@ -49,7 +49,14 @@ export default function postMentionPreviews() { if (!visible) { var showPost = function(post) { m.render($preview[0], m('li', PostPreview.component({post}))); - } + positionPreview(); + }; + + // Position the preview so that it appears above the mention. + // (The offsetParent should be .post-body.) + var positionPreview = function() { + $preview.show().css('top', $this.offset().top - $this.offsetParent().offset().top - $preview.outerHeight(true)); + }; var post = discussion.posts().filter(post => post && post.number() == number)[0]; if (post) { @@ -57,11 +64,9 @@ export default function postMentionPreviews() { } else { m.render($preview[0], LoadingIndicator.component()); app.store.find('posts', {discussions: discussion.id(), number}).then(posts => showPost(posts[0])); + positionPreview(); } - // Position the preview so that it appears above the mention. - // (The offsetParent should be .post-body.) - $preview.show().css('top', $this.offset().top - $this.offsetParent().offset().top - $preview.outerHeight(true)); setTimeout(() => $preview.off('transitionend').addClass('in')); } }, 500);