Add checks to menu double tap so it doesn't fire if the user swipes fast
This commit is contained in:
parent
6d24a21870
commit
8b997bcb63
1 changed files with 10 additions and 3 deletions
|
@ -76,7 +76,8 @@ on the deck container.
|
|||
|
||||
$d.bind('deck.init', function() {
|
||||
var opts = $[deck]('getOptions'),
|
||||
touchEndTime = 0;
|
||||
touchEndTime = 0,
|
||||
currentSlide;
|
||||
|
||||
// Bind key events
|
||||
$d.bind('keydown.deck', function(e) {
|
||||
|
@ -86,14 +87,20 @@ on the deck container.
|
|||
});
|
||||
|
||||
// Double tap to toggle slide menu for touch devices
|
||||
$[deck]('getContainer').bind('touchend.deck', function(e) {
|
||||
$[deck]('getContainer').bind('touchstart.deck', function(e) {
|
||||
currentSlide = $[deck]('getSlide');
|
||||
})
|
||||
.bind('touchend.deck', function(e) {
|
||||
var now = Date.now();
|
||||
|
||||
// Ignore this touch event if it caused a nav change (swipe)
|
||||
if (currentSlide !== $[deck]('getSlide')) return;
|
||||
|
||||
if (now - touchEndTime < opts.touch.doubletapWindow) {
|
||||
$[deck]('toggleMenu');
|
||||
e.preventDefault();
|
||||
}
|
||||
touchEndTime = now;
|
||||
e.preventDefault();
|
||||
});
|
||||
})
|
||||
.bind('deck.change', function(e, from, to) {
|
||||
|
|
Loading…
Reference in a new issue