|
1 | 1 | /*! |
2 | | - * SlickNav Responsive Mobile Menu v1.0.7 |
| 2 | + * SlickNav Responsive Mobile Menu v1.0.8 |
3 | 3 | * (c) 2016 Josh Cope |
4 | 4 | * licensed under MIT |
5 | 5 | */ |
|
25 | 25 | removeClasses: false, |
26 | 26 | removeStyles: false, |
27 | 27 | brand: '', |
| 28 | + animations: 'jquery', |
28 | 29 | init: function () {}, |
29 | 30 | beforeOpen: function () {}, |
30 | 31 | beforeClose: function () {}, |
|
333 | 334 | if (animate) { |
334 | 335 | duration = settings.duration; |
335 | 336 | } |
| 337 | + |
| 338 | + function afterOpen(trigger, parent) { |
| 339 | + $(trigger).removeClass(prefix+'_animating'); |
| 340 | + $(parent).removeClass(prefix+'_animating'); |
| 341 | + |
| 342 | + //Fire afterOpen callback |
| 343 | + if (!init) { |
| 344 | + settings.afterOpen(trigger); |
| 345 | + } |
| 346 | + } |
| 347 | + |
| 348 | + function afterClose(trigger, parent) { |
| 349 | + el.attr('aria-hidden','true'); |
| 350 | + items.attr('tabindex', '-1'); |
| 351 | + $this._setVisAttr(el, true); |
| 352 | + el.hide(); //jQuery 1.7 bug fix |
| 353 | + |
| 354 | + $(trigger).removeClass(prefix+'_animating'); |
| 355 | + $(parent).removeClass(prefix+'_animating'); |
| 356 | + |
| 357 | + //Fire init or afterClose callback |
| 358 | + if (!init){ |
| 359 | + settings.afterClose(trigger); |
| 360 | + } else if (trigger == 'init'){ |
| 361 | + settings.init(); |
| 362 | + } |
| 363 | + } |
336 | 364 |
|
337 | 365 | if (el.hasClass(prefix+'_hidden')) { |
338 | 366 | el.removeClass(prefix+'_hidden'); |
339 | 367 | //Fire beforeOpen callback |
340 | | - if (!init) { |
341 | | - settings.beforeOpen(trigger); |
342 | | - } |
343 | | - el.slideDown(duration, settings.easingOpen, function(){ |
344 | | - |
345 | | - $(trigger).removeClass(prefix+'_animating'); |
346 | | - $(parent).removeClass(prefix+'_animating'); |
347 | | - |
348 | | - //Fire afterOpen callback |
349 | | - if (!init) { |
350 | | - settings.afterOpen(trigger); |
351 | | - } |
352 | | - }); |
| 368 | + if (!init) { |
| 369 | + settings.beforeOpen(trigger); |
| 370 | + } |
| 371 | + if (settings.animations === 'jquery') { |
| 372 | + el.stop(true,true).slideDown(duration, settings.easingOpen, function(){ |
| 373 | + afterOpen(trigger, parent); |
| 374 | + }); |
| 375 | + } else if(settings.animations === 'velocity') { |
| 376 | + el.velocity("finish").velocity("slideDown", { |
| 377 | + easing: settings.easingOpen, |
| 378 | + complete: function() { |
| 379 | + afterOpen(trigger, parent); |
| 380 | + } |
| 381 | + }); |
| 382 | + } |
353 | 383 | el.attr('aria-hidden','false'); |
354 | 384 | items.attr('tabindex', '0'); |
355 | 385 | $this._setVisAttr(el, false); |
|
361 | 391 | settings.beforeClose(trigger); |
362 | 392 | } |
363 | 393 |
|
364 | | - el.slideUp(duration, this.settings.easingClose, function() { |
365 | | - el.attr('aria-hidden','true'); |
366 | | - items.attr('tabindex', '-1'); |
367 | | - $this._setVisAttr(el, true); |
368 | | - el.hide(); //jQuery 1.7 bug fix |
369 | | - |
370 | | - $(trigger).removeClass(prefix+'_animating'); |
371 | | - $(parent).removeClass(prefix+'_animating'); |
372 | | - |
373 | | - //Fire init or afterClose callback |
374 | | - if (!init){ |
375 | | - settings.afterClose(trigger); |
376 | | - } else if (trigger == 'init'){ |
377 | | - settings.init(); |
378 | | - } |
379 | | - }); |
| 394 | + if (settings.animations === 'jquery') { |
| 395 | + el.stop(true,true).slideUp(duration, this.settings.easingClose, function() { |
| 396 | + afterClose(trigger, parent) |
| 397 | + }); |
| 398 | + } else if (settings.animations === 'velocity') { |
| 399 | + |
| 400 | + el.velocity("finish").velocity("slideUp", { |
| 401 | + easing: settings.easingClose, |
| 402 | + complete: function() { |
| 403 | + afterClose(trigger, parent); |
| 404 | + } |
| 405 | + }); |
| 406 | + } |
380 | 407 | } |
381 | 408 | }; |
382 | 409 |
|
|
0 commit comments