diff --git a/lib/features/context-pad/ContextPad.js b/lib/features/context-pad/ContextPad.js index 6a87cc05c..a757ceba6 100644 --- a/lib/features/context-pad/ContextPad.js +++ b/lib/features/context-pad/ContextPad.js @@ -611,29 +611,34 @@ ContextPad.prototype._getPosition = function(target) { * Update context pad position. */ ContextPad.prototype._updatePosition = function() { - if (!this.isOpen()) { - return; - } - var html = this._current.html; + const updateFn = () => { + if (!this.isOpen()) { + return; + } - var position = this._getPosition(this._current.target); + var html = this._current.html; - if ('x' in position && 'y' in position) { - html.style.left = position.x + 'px'; - html.style.top = position.y + 'px'; - } else { - [ - 'top', - 'right', - 'bottom', - 'left' - ].forEach(function(key) { - if (key in position) { - html.style[ key ] = position[ key ] + 'px'; - } - }); - } + var position = this._getPosition(this._current.target); + + if ('x' in position && 'y' in position) { + html.style.left = position.x + 'px'; + html.style.top = position.y + 'px'; + } else { + [ + 'top', + 'right', + 'bottom', + 'left' + ].forEach(function(key) { + if (key in position) { + html.style[ key ] = position[ key ] + 'px'; + } + }); + } + }; + + this._scheduler.schedule(updateFn, 'ContextPad#_updatePosition'); }; /**