Eject from show/hide menu if already in the same state, fixes #57

This commit is contained in:
imakewebthings 2011-12-04 21:08:04 +08:00
parent 54d0f5c665
commit e1ba017e0e
2 changed files with 13 additions and 0 deletions

View file

@ -53,6 +53,8 @@ on the deck container.
var $c = $[deck]('getContainer'),
opts = $[deck]('getOptions');
if ($c.hasClass(opts.classes.menu)) return;
// Hide through loading class to short-circuit transitions (perf)
$c.addClass([opts.classes.loading, opts.classes.menu].join(' '));
@ -86,6 +88,8 @@ on the deck container.
var $c = $[deck]('getContainer'),
opts = $[deck]('getOptions');
if (!$c.hasClass(opts.classes.menu)) return;
$c.removeClass(opts.classes.menu);
$c.addClass(opts.classes.loading);

View file

@ -19,6 +19,15 @@ describe('Deck JS Menu', function() {
$.deck('showMenu');
expect($(dsc)).toHaveClass(defaults.classes.menu);
});
it('should do nothing if menu is already showing', function() {
if (Modernizr.csstransforms) {
$.deck('showMenu');
$.deck('showMenu');
$.deck('hideMenu');
expect($('.slide').attr('style')).toBeFalsy();
}
});
});
describe('hideMenu()', function() {