Browse Source

Finish adding useFlex setting for dimmer/modal

legacy-modals
Jack Lukic 6 years ago
parent
commit
e609212888
4 changed files with 52 additions and 6 deletions
  1. 11
      RELEASE-NOTES.md
  2. 16
      src/definitions/modules/dimmer.js
  3. 6
      src/definitions/modules/dimmer.less
  4. 25
      src/definitions/modules/modal.js

11
RELEASE-NOTES.md

@ -1,5 +1,16 @@
## RELEASE NOTES ## RELEASE NOTES
### Version 2.3.4 - Aug xx, 2018
**Enhancements**
- **Modal/Dimmer** - Modals and dimmers now include a new setting `useFlex` which defaults to `auto`. Modals and dimmers will automatically revert to using non-flex layouts when there may be layout issues with using flexbox.
For example when `attachable: false` is used with a modal, or if IE11/Edge is used (Absolutely positioned elements inside flex containers in IE behave differently)
### Version 2.3.3 - June 18, 2018 ### Version 2.3.3 - June 18, 2018
**Bug Fixes** **Bug Fixes**

16
src/definitions/modules/dimmer.js

@ -252,7 +252,7 @@ $.fn.dimmer = function(parameters) {
} }
$dimmer $dimmer
.transition({ .transition({
displayType : settings.useFlex
displayType : module.can.useFlex()
? 'flex' ? 'flex'
: 'block', : 'block',
animation : settings.transition + ' in', animation : settings.transition + ' in',
@ -299,7 +299,9 @@ $.fn.dimmer = function(parameters) {
module.verbose('Hiding dimmer with css'); module.verbose('Hiding dimmer with css');
$dimmer $dimmer
.transition({ .transition({
displayType : 'flex',
displayType : module.can.useFlex()
? 'flex'
: 'block',
animation : settings.transition + ' out', animation : settings.transition + ' out',
queue : false, queue : false,
duration : module.get.duration(), duration : module.get.duration(),
@ -361,6 +363,13 @@ $.fn.dimmer = function(parameters) {
active: function() { active: function() {
return $dimmer.hasClass(className.active); return $dimmer.hasClass(className.active);
}, },
ie: function() {
var
isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
isIE = ('ActiveXObject' in window)
;
return (isIE11 || isIE);
},
animating: function() { animating: function() {
return ( $dimmer.is(':animated') || $dimmer.hasClass(className.animating) ); return ( $dimmer.is(':animated') || $dimmer.hasClass(className.animating) );
}, },
@ -398,8 +407,7 @@ $.fn.dimmer = function(parameters) {
can: { can: {
useFlex: function() { useFlex: function() {
// test for IE11/edge
return true;
return !module.is.ie();
}, },
show: function() { show: function() {
return !$dimmer.hasClass(className.disabled); return !$dimmer.hasClass(className.disabled);

6
src/definitions/modules/dimmer.less

@ -125,6 +125,12 @@
display: block; display: block;
} }
/* Resort to normal positioning */
.ui.legacy.page.dimmer > .ui.modal {
top: 50%;
left: 50%;
}
/*-------------- /*--------------
Alignment Alignment
---------------*/ ---------------*/

25
src/definitions/modules/modal.js

@ -168,6 +168,9 @@ $.fn.modal = function(parameters) {
refresh: function() { refresh: function() {
module.remove.scrolling(); module.remove.scrolling();
module.cacheSizes(); module.cacheSizes();
if(!module.can.useFlex()) {
module.set.modalOffset();
}
module.set.screenHeight(); module.set.screenHeight();
module.set.type(); module.set.type();
}, },
@ -326,6 +329,9 @@ $.fn.modal = function(parameters) {
module.showDimmer(); module.showDimmer();
module.cacheSizes(); module.cacheSizes();
if(!module.can.useFlex()) {
module.set.modalOffset();
}
module.set.screenHeight(); module.set.screenHeight();
module.set.type(); module.set.type();
module.set.clickaway(); module.set.clickaway();
@ -550,11 +556,13 @@ $.fn.modal = function(parameters) {
$module.addClass(className.loading); $module.addClass(className.loading);
var var
scrollHeight = $module.prop('scrollHeight'), scrollHeight = $module.prop('scrollHeight'),
modalWidth = $module.outerWidth(),
modalHeight = $module.outerHeight() modalHeight = $module.outerHeight()
; ;
if(module.cache === undefined || modalHeight !== 0) { if(module.cache === undefined || modalHeight !== 0) {
module.cache = { module.cache = {
pageHeight : $(document).outerHeight(), pageHeight : $(document).outerHeight(),
width : modalWidth,
height : modalHeight + settings.offset, height : modalHeight + settings.offset,
scrollHeight : scrollHeight + settings.offset, scrollHeight : scrollHeight + settings.offset,
contextHeight : (settings.context == 'body') contextHeight : (settings.context == 'body')
@ -569,7 +577,7 @@ $.fn.modal = function(parameters) {
can: { can: {
useFlex: function() { useFlex: function() {
return $dimmer.dimmer('can use flex');
return settings.detachable && $dimmer.dimmer('can use flex');
}, },
fit: function() { fit: function() {
var var
@ -633,6 +641,7 @@ $.fn.modal = function(parameters) {
var var
defaultSettings = { defaultSettings = {
debug : settings.debug, debug : settings.debug,
useFlex : module.can.useFlex(),
dimmerName : 'modals', dimmerName : 'modals',
closable : 'auto', closable : 'auto',
variation : settings.centered variation : settings.centered
@ -664,6 +673,18 @@ $.fn.modal = function(parameters) {
} }
$context.dimmer('setting', dimmerSettings); $context.dimmer('setting', dimmerSettings);
}, },
modalOffset: function() {
var
width = module.cache.width,
height = module.cache.height
;
$module
.css({
marginTop: -(height / 2),
marginLeft: -(width / 2)
})
;
},
screenHeight: function() { screenHeight: function() {
if( module.can.fit() ) { if( module.can.fit() ) {
$body.css('height', ''); $body.css('height', '');
@ -888,6 +909,7 @@ $.fn.modal.settings = {
namespace : 'modal', namespace : 'modal',
useFlex : 'auto', useFlex : 'auto',
offset : 0,
silent : false, silent : false,
debug : false, debug : false,
@ -918,7 +940,6 @@ $.fn.modal.settings = {
queue : false, queue : false,
duration : 500, duration : 500,
offset : 0,
transition : 'scale', transition : 'scale',
// padding with edge of page // padding with edge of page

Loading…
Cancel
Save