mhfen / swipe-detect Goto Github PK
View Code? Open in Web Editor NEWA touchevent swipe detection utility for JavaScript applications.
License: MIT License
A touchevent swipe detection utility for JavaScript applications.
License: MIT License
The recordTouchStartValues and detectSwipeDirection event listener callbacks binding is wrong, should be bind to this to work correctly.
Getting the following error message, while trying to implement the package in my Electron app
App threw an error during load
C:\Users\folder\node_modules\swipe-detect\dist\index.js:98
export default function(target, callback, threshold=150) {
^^^^^^
SyntaxError: Unexpected token export
at Module._compile (internal/modules/cjs/loader.js:752:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:820:10)
at Module.load (internal/modules/cjs/loader.js:677:32)
at tryModuleLoad (internal/modules/cjs/loader.js:609:12)
at Function.Module._load (internal/modules/cjs/loader.js:601:3)
at Module.require (internal/modules/cjs/loader.js:715:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (C:\Users\folder\main.js:17:22)
at Module._compile (internal/modules/cjs/loader.js:808:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:820:10)
This listeners can not be removed.
this.target.addEventListener('touchstart', this.recordTouchStartValues.bind(this));
this.target.addEventListener('touchend', this.detectSwipeDirection.bind(this));
Because this.recordTouchStartValues.bind(this) !== this.recordTouchStartValues.bind(this)
(the pointer is new every time bind is called).
So the function disable()
will not remove the listeners.
Please store this.xxx.bind(this)
in variables and add and remove listeners with the same variables.
Can you add a parameter in swipeDetect function? @mhfen
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.