-
-
Save micwehrle/e654cf83d27b2ec3e72f33b5ea482b3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper { | |
height: 100vh; | |
width: 100vw; | |
background-color: green; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrapper"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var el = document.querySelector('.wrapper'); | |
var touchDetector = new Hammer(el); | |
touchDetector.get('swipe').set({ | |
direction: Hammer.DIRECTION_VERTICAL | |
}); | |
touchDetector.get('press').set({ | |
time: 1000 | |
}); | |
function removeSecondListener() { | |
console.log('second listener removed'); | |
touchDetector.off('press', secondGesture); | |
} | |
var timeoutForSecondGesture; | |
function firstGesture(e) { | |
touchDetector.on('press', secondGesture); | |
timeoutForSecondGesture = setTimeout(removeSecondListener, 2000); | |
} | |
function secondGesture(e) { | |
clearTimeout(timeoutForSecondGesture); | |
console.log(e); | |
removeSecondListener(); | |
} | |
touchDetector.on('swipeup', firstGesture); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment