From d0206eb8e795b2f1f539c06edd0cdefe882239c8 Mon Sep 17 00:00:00 2001 From: jlukic Date: Tue, 8 Oct 2013 12:32:52 -0400 Subject: [PATCH] Adds duration object for dimmer, modal now always appears quicker than and hides later than modal preventing issues with callbacks --- src/modules/dimmer.js | 24 +++++++++++++++++++----- src/modules/modal.js | 11 +++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/modules/dimmer.js b/src/modules/dimmer.js index 8d24f0480..b6101436e 100755 --- a/src/modules/dimmer.js +++ b/src/modules/dimmer.js @@ -151,7 +151,7 @@ $.fn.dimmer = function(parameters) { module.set.dimmed(); if($.fn.transition !== undefined) { $dimmer - .transition(settings.transition + ' in', settings.duration, function() { + .transition(settings.transition + ' in', module.get.duration(), function() { module.set.active(); callback(); }) @@ -166,7 +166,7 @@ $.fn.dimmer = function(parameters) { width : '100%', height : '100%' }) - .fadeTo(settings.duration, 1, function() { + .fadeTo(module.get.duration(), 1, function() { $dimmer.removeAttr('style'); module.set.active(); callback(); @@ -180,7 +180,7 @@ $.fn.dimmer = function(parameters) { if($.fn.transition !== undefined) { module.verbose('Hiding dimmer with css'); $dimmer - .transition(settings.transition + ' out', settings.duration, function() { + .transition(settings.transition + ' out', module.get.duration(), function() { module.remove.active(); callback(); }) @@ -190,7 +190,7 @@ $.fn.dimmer = function(parameters) { module.verbose('Hiding dimmer with javascript'); $dimmer .stop() - .fadeOut(settings.duration, function() { + .fadeOut(module.get.duration(), function() { $dimmer.removeAttr('style'); module.remove.active(); callback(); @@ -203,6 +203,17 @@ $.fn.dimmer = function(parameters) { get: { dimmer: function() { return $dimmer; + }, + duration: function() { + if(typeof settings.duration == 'object') { + if( module.is.active() ) { + return settings.duration.hide; + } + else { + return settings.duration.show; + } + } + return settings.duration; } }, @@ -512,7 +523,10 @@ $.fn.dimmer.settings = { on : false, closable : true, - duration : 500, + duration : { + show : 500, + hide : 500 + }, onChange : function(){}, onShow : function(){}, diff --git a/src/modules/modal.js b/src/modules/modal.js index f07bad1da..fa32e9539 100755 --- a/src/modules/modal.js +++ b/src/modules/modal.js @@ -197,7 +197,7 @@ $.fn.modal = function(parameters) { module.debug('Hiding modal'); // remove keyboard detection $document - .off('keyup.' + namespace) + .off('keyup.' + eventNamespace) ; if(settings.transition && $.fn.transition !== undefined) { $module @@ -242,7 +242,7 @@ $.fn.modal = function(parameters) { restore: { focus: function() { - $focusedElement.focus(); + $focusedElement.focus(); } }, @@ -292,7 +292,10 @@ $.fn.modal = function(parameters) { module.debug('Setting dimmer settings', settings.closable); $context .dimmer('setting', 'closable', settings.closable) - .dimmer('setting', 'duration', settings.duration * 0.75) + .dimmer('setting', 'duration', { + show : settings.duration * 0.95, + hide : settings.duration * 1.05 + }) .dimmer('setting', 'onShow' , module.add.keyboardShortcuts) .dimmer('setting', 'onHide', function() { module.hide(); @@ -526,7 +529,7 @@ $.fn.modal.settings = { closable : true, context : 'body', - duration : 600, + duration : 500, easing : 'easeOutExpo', offset : 0, transition : 'scale',