Skip to content

Instantly share code, notes, and snippets.

@omar2205
Created January 13, 2022 23:10
Show Gist options
  • Save omar2205/3222d1eb8071c09a33713125a4455184 to your computer and use it in GitHub Desktop.
Save omar2205/3222d1eb8071c09a33713125a4455184 to your computer and use it in GitHub Desktop.
Hammerjs edge swipe
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