From 7782b19e997edd23a30080f089f500de4028523c Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 4 May 2016 11:53:46 +0200 Subject: [PATCH] Do not set offset initially, sometimes ended up overflowing parent element. Do calculation before setting popup offset. HFJ-1867 --- js/h5p-confirmation-dialog.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/h5p-confirmation-dialog.js b/js/h5p-confirmation-dialog.js index 01fa1d7..1d08ab6 100644 --- a/js/h5p-confirmation-dialog.js +++ b/js/h5p-confirmation-dialog.js @@ -154,9 +154,13 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { /** * Fit popup to container. Makes sure it doesn't overflow. + * @params {number} [offsetTop] Offset of popup */ - var fitToContainer = function () { + var fitToContainer = function (offsetTop) { var popupOffsetTop = parseInt(popup.style.top, 10); + if (offsetTop) { + popupOffsetTop = offsetTop; + } // Overflows height if (popupOffsetTop + popup.offsetHeight > wrapperElement.offsetHeight) { @@ -178,9 +182,8 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { * @returns {H5P.ConfirmationDialog} */ this.show = function (offsetTop) { - popup.style.top = offsetTop + 'px'; popupBackground.classList.remove('hidden'); - fitToContainer(); + fitToContainer(offsetTop); setTimeout(function () { popup.classList.remove('hidden'); popupBackground.classList.remove('hiding');