diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index c4119882e..647ade706 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -535,24 +535,41 @@ $.fn.modal = function(parameters) { }, cacheSizes: function() { + $module.addClass(className.loading); var - modalHeight = $module.outerHeight() + scrollHeight = $module.prop('scrollHeight'), + modalHeight = $module.outerHeight() ; if(module.cache === undefined || modalHeight !== 0) { module.cache = { pageHeight : $(document).outerHeight(), height : modalHeight + settings.offset, + scrollHeight : scrollHeight + settings.offset, contextHeight : (settings.context == 'body') ? $(window).height() - : $dimmable.height() + : $dimmable.height(), }; + module.cache.topOffset = -(module.cache.height / 2); } + $module.removeClass(className.loading); module.debug('Caching modal and container sizes', module.cache); }, can: { fit: function() { - return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight); + var + contextHeight = module.cache.contextHeight, + verticalCenter = module.cache.contextHeight / 2, + topOffset = module.cache.topOffset, + scrollHeight = module.cache.scrollHeight, + height = module.cache.height, + paddingHeight = settings.padding, + startPosition = (verticalCenter + topOffset) + ; + return (scrollHeight > height) + ? (startPosition + scrollHeight + paddingHeight < contextHeight) + : (height + (paddingHeight * 2) < contextHeight) + ; } }, @@ -667,7 +684,7 @@ $.fn.modal = function(parameters) { $module .css({ top: '', - marginTop: -(module.cache.height / 2) + marginTop: module.cache.topOffset }) ; } @@ -940,6 +957,7 @@ $.fn.modal.settings = { animating : 'animating', blurring : 'blurring', inverted : 'inverted', + loading : 'loading', scrolling : 'scrolling', undetached : 'undetached' } diff --git a/src/definitions/modules/modal.less b/src/definitions/modules/modal.less index 8d9f10d8e..eb9f42a17 100755 --- a/src/definitions/modules/modal.less +++ b/src/definitions/modules/modal.less @@ -323,6 +323,12 @@ States *******************************/ +.ui.loading.modal { + display: block; + visibility: hidden; + z-index: @loadingZIndex; +} + .ui.active.modal { display: block; } diff --git a/src/themes/default/modules/modal.variables b/src/themes/default/modules/modal.variables index 55146c9fd..6825b0fde 100755 --- a/src/themes/default/modules/modal.variables +++ b/src/themes/default/modules/modal.variables @@ -97,6 +97,12 @@ /* Coupling */ @invertedBoxShadow: 1px 3px 10px 2px rgba(0, 0, 0, 0.2); +/*------------------- + States +--------------------*/ + +@loadingZIndex: -1; + /*------------------- Types --------------------*/