Created
January 13, 2022 23:10
-
-
Save omar2205/3222d1eb8071c09a33713125a4455184 to your computer and use it in GitHub Desktop.
Hammerjs edge swipe
This file contains hidden or 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
import Hammer from "https://cdn.skypack.dev/[email protected]"; | |
var hammertime = new Hammer(document.querySelector('html'), {}); | |
hammertime.on('swiperight', e => { | |
const endPoint = e.pointers[0].pageX | |
const distance = e.distance | |
const origin = endPoint - distance | |
// swipe only within 10px from the edge | |
if (origin <= 10) | |
console.log(e) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment