Skip to content

Commit

Permalink
Fixes #5578, absolute positioned modal items are now taken into scrol…
Browse files Browse the repository at this point in the history
…l calculation
  • Loading branch information
jlukic committed Aug 7, 2017
1 parent 2849c90 commit 7450aa3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
}
},

Expand Down Expand Up @@ -667,7 +684,7 @@ $.fn.modal = function(parameters) {
$module
.css({
top: '',
marginTop: -(module.cache.height / 2)
marginTop: module.cache.topOffset
})
;
}
Expand Down Expand Up @@ -940,6 +957,7 @@ $.fn.modal.settings = {
animating : 'animating',
blurring : 'blurring',
inverted : 'inverted',
loading : 'loading',
scrolling : 'scrolling',
undetached : 'undetached'
}
Expand Down
6 changes: 6 additions & 0 deletions src/definitions/modules/modal.less
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@
States
*******************************/

.ui.loading.modal {
display: block;
visibility: hidden;
z-index: @loadingZIndex;
}

.ui.active.modal {
display: block;
}
Expand Down
6 changes: 6 additions & 0 deletions src/themes/default/modules/modal.variables
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
/* Coupling */
@invertedBoxShadow: 1px 3px 10px 2px rgba(0, 0, 0, 0.2);

/*-------------------
States
--------------------*/

@loadingZIndex: -1;

/*-------------------
Types
--------------------*/
Expand Down

0 comments on commit 7450aa3

Please sign in to comment.