Browse Source

Fixes #5578, absolute positioned modal items are now taken into scroll calculation

revert-5543-next
Jack 7 years ago
parent
commit
7450aa3c9c
3 changed files with 34 additions and 4 deletions
  1. 26
      src/definitions/modules/modal.js
  2. 6
      src/definitions/modules/modal.less
  3. 6
      src/themes/default/modules/modal.variables

26
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'
}

6
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;
}

6
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
--------------------*/

Loading…
Cancel
Save