2014-12-12

Pure JavaScript Swipe Event Plugin for PC and Mobile Web

Views: 12079 | Add Comments

I tried many JavaScript Swipe event plugins, such as the jQuery mobile swipe plugin, and the jQuery.event.swipe by stephband, and many others. Unfortunately, none of them works for me. Many weakness of those code that I made decision not using them:

The demos provided are so poor, they are not interesting.

The swipe event is fired only after the touch ends(your finger lift off the screen, or release the mouse button), so your event handler is so delayed to the user, that’s why the UI is not smooth. There must be move events before the swipe event fires.

Treats swipe event as a serial of move events. In this way, you provide only one event handler just like you provide for Mac’s trackpad scroll events. The Mac trackpad hardware driver gurantees to generate smooth small scroll events.

So, with my JavaScript swipe event plugin, your code would be as simple as:

guesture.onmove = function(e){
	layer.x += e.dx;
	layer.y += e.dy;
}

Check out the exciting demo online! With PC chrome browser, or with your iPhone Safari, it is PC and Mobile compatible.

Posted by ideawu at 2014-12-12 16:55:56 Tags:

Leave a Comment