From 6a845599c638513c75b8f04880965314099988b4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 1 Jul 2016 09:51:12 +0200 Subject: [PATCH] [show-hint addon] Move call to getScrollInto to avoid a reflow --- addon/hint/show-hint.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 64ec9289cc..604bd3b715 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -230,6 +230,8 @@ (completion.options.container || document.body).appendChild(hints); var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; var scrolls = hints.scrollHeight > hints.clientHeight + 1 + var startScroll = cm.getScrollInfo(); + if (overlapY > 0) { var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); if (curTop - height > 0) { // Fits above cursor @@ -273,7 +275,6 @@ cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); }); } - var startScroll = cm.getScrollInfo(); cm.on("scroll", this.onScroll = function() { var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); var newTop = top + startScroll.top - curScroll.top;