Do not set offset initially, sometimes ended up overflowing parent element.
Do calculation before setting popup offset. HFJ-1867pull/23/head
parent
6e7e144900
commit
7782b19e99
|
@ -154,9 +154,13 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fit popup to container. Makes sure it doesn't overflow.
|
* 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);
|
var popupOffsetTop = parseInt(popup.style.top, 10);
|
||||||
|
if (offsetTop) {
|
||||||
|
popupOffsetTop = offsetTop;
|
||||||
|
}
|
||||||
|
|
||||||
// Overflows height
|
// Overflows height
|
||||||
if (popupOffsetTop + popup.offsetHeight > wrapperElement.offsetHeight) {
|
if (popupOffsetTop + popup.offsetHeight > wrapperElement.offsetHeight) {
|
||||||
|
@ -178,9 +182,8 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
||||||
* @returns {H5P.ConfirmationDialog}
|
* @returns {H5P.ConfirmationDialog}
|
||||||
*/
|
*/
|
||||||
this.show = function (offsetTop) {
|
this.show = function (offsetTop) {
|
||||||
popup.style.top = offsetTop + 'px';
|
|
||||||
popupBackground.classList.remove('hidden');
|
popupBackground.classList.remove('hidden');
|
||||||
fitToContainer();
|
fitToContainer(offsetTop);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
popup.classList.remove('hidden');
|
popup.classList.remove('hidden');
|
||||||
popupBackground.classList.remove('hiding');
|
popupBackground.classList.remove('hiding');
|
||||||
|
|
Loading…
Reference in New Issue