Skip to content

Commit 4418720

Browse files
SteveTheTechiemlh758
authored andcommitted
Fix #775 - Animation / positioning sequence
Position / set dimensions of menu before doing animation. Add this.element.trigger('blur') to close() Hide menu for animation effects. Some animation effects (e.g. fade) require the menu to be hidden and shown w/ the effect to work properly. For example, if the menu is already displayed, fade will make it hidden.
1 parent fcbcf38 commit 4418720

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/jquery.multiselect.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,25 +1381,26 @@
13811381
// set the scroll of the checkbox container
13821382
this.$checkboxes.scrollTop(0);
13831383

1384-
// show the menu, maybe with a speed/effect combo
1384+
// Show the menu, set its dimensions, and position it.
1385+
$menu.css('display','block');
1386+
this._setMenuWidth();
1387+
this._setMenuHeight();
1388+
this.position();
1389+
1390+
// Do any specified open animation effect after positioning the menu.
13851391
if (!!effect) {
1392+
// Menu must be hidden for some effects (e.g. fade) to work.
1393+
$menu.css('display','none');
13861394
if (typeof effect == 'string') {
1387-
$.fn.show.call($menu, effect, this.speed);
1395+
$menu.show(effect, this.speed);
13881396
}
13891397
else if (typeof effect == 'object' && effect.constructor == Array) {
1390-
$.fn.show.call($menu, effect[0], effect[1] || this.speed);
1398+
$menu.show(effect[0], effect[1] || this.speed);
13911399
}
13921400
else if (typeof effect == 'object' && effect.constructor == Object) {
1393-
$.fn.show.call($menu, effect);
1401+
$menu.show(effect);
13941402
}
13951403
}
1396-
else {
1397-
$menu.css('display','block');
1398-
}
1399-
1400-
this._setMenuWidth();
1401-
this._setMenuHeight();
1402-
this.position();
14031404

14041405
// focus the first not disabled option or filter input if available
14051406
var filter = $header.find(".ui-multiselect-filter");
@@ -1439,20 +1440,21 @@
14391440
// hide the menu, maybe with a speed/effect combo
14401441
if (!!effect) {
14411442
if (typeof effect == 'string') {
1442-
$.fn.hide.call($menu, effect, this.speed);
1443+
$menu.hide(effect, this.speed);
14431444
}
14441445
else if (typeof effect == 'object' && effect.constructor == Array) {
1445-
$.fn.hide.call($menu, effect[0], effect[1] || this.speed);
1446+
$menu.hide(effect[0], effect[1] || this.speed);
14461447
}
14471448
else if (typeof effect == 'object' && effect.constructor == Object) {
1448-
$.fn.hide.call($menu, effect);
1449+
$menu.hide(effect);
14491450
}
14501451
}
14511452
else {
14521453
$menu.css('display','none');
14531454
}
14541455

14551456
$button.removeClass('ui-state-active').trigger('blur').trigger('mouseleave');
1457+
this.element.trigger('blur'); // For jQuery Validate
14561458
this._isOpen = false;
14571459
this._trigger('close');
14581460
$button.trigger('focus');

0 commit comments

Comments
 (0)