Skip to content

Commit

Permalink
feat(dropdown,popup): support individual show and hide transition and…
Browse files Browse the repository at this point in the history
… duration

This PR adds optional support for individual setting of transition method and duration to the dropdown and popup module.

We already have the same optional setting in toast, modal and dimmer, so this PR concludes a unique syntax.
Because the settings are optional, this change is 100% backwards compatible.
  • Loading branch information
lubber-de authored May 18, 2021
1 parent 6e4ff1d commit a5d471c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ $.fn.dropdown = function(parameters) {
return count;
},
transition: function($subMenu) {
return (settings.transition == 'auto')
return (settings.transition === 'auto')
? module.is.upward($subMenu)
? 'slide up'
: 'slide down'
Expand Down Expand Up @@ -3620,12 +3620,12 @@ $.fn.dropdown = function(parameters) {
;
module.verbose('Doing menu show animation', $currentMenu);
module.set.direction($subMenu);
transition = module.get.transition($subMenu);
transition = settings.transition.showMethod || module.get.transition($subMenu);
if( module.is.selection() ) {
module.set.scrollPosition(module.get.selectedItem(), true);
}
if( module.is.hidden($currentMenu) || module.is.animating($currentMenu) ) {
if(transition == 'none') {
if(transition === 'none') {
start();
$currentMenu.transition({
displayType: module.get.displayType()
Expand All @@ -3638,7 +3638,7 @@ $.fn.dropdown = function(parameters) {
animation : transition + ' in',
debug : settings.debug,
verbose : settings.verbose,
duration : settings.duration,
duration : settings.transition.showDuration || settings.duration,
queue : true,
onStart : start,
displayType: module.get.displayType(),
Expand All @@ -3664,7 +3664,7 @@ $.fn.dropdown = function(parameters) {
}
module.remove.active();
},
transition = module.get.transition($subMenu)
transition = settings.transition.hideMethod || module.get.transition($subMenu)
;
callback = $.isFunction(callback)
? callback
Expand All @@ -3673,7 +3673,7 @@ $.fn.dropdown = function(parameters) {
if( module.is.visible($currentMenu) || module.is.animating($currentMenu) ) {
module.verbose('Doing menu hide animation', $currentMenu);

if(transition == 'none') {
if(transition === 'none') {
start();
$currentMenu.transition({
displayType: module.get.displayType()
Expand All @@ -3684,7 +3684,7 @@ $.fn.dropdown = function(parameters) {
$currentMenu
.transition({
animation : transition + ' out',
duration : settings.duration,
duration : settings.transition.hideDuration || settings.duration,
debug : settings.debug,
verbose : settings.verbose,
queue : false,
Expand Down
8 changes: 4 additions & 4 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ $.fn.popup = function(parameters) {
module.set.visible();
$popup
.transition({
animation : settings.transition + ' in',
animation : (settings.transition.showMethod || settings.transition) + ' in',
queue : false,
debug : settings.debug,
verbose : settings.verbose,
duration : settings.duration,
duration : settings.transition.showDuration || settings.duration,
onComplete : function() {
module.bind.close();
callback.call($popup, element);
Expand All @@ -457,9 +457,9 @@ $.fn.popup = function(parameters) {
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
$popup
.transition({
animation : settings.transition + ' out',
animation : (settings.transition.hideMethod || settings.transition) + ' out',
queue : false,
duration : settings.duration,
duration : settings.transition.hideDuration || settings.duration,
debug : settings.debug,
verbose : settings.verbose,
onComplete : function() {
Expand Down

0 comments on commit a5d471c

Please sign in to comment.