Simulate swipe with mouse in javascript
Asked Answered
T

5

20

I'm trying to make an image rotator that works on mobile devices using swipe for navigation. I'm also trying to make the same rotator to work on PC browsers but to be able to use the mouse drag to simulate swipe. Any good ideeas?

Tupelo answered 25/10, 2011 at 19:4 Comment(0)
D
8

You'll want to handle onmousedown, onmousemove, and onmouseup events, keeping track of the mouse position and manipulating your image rotator accordingly.

Diver answered 25/10, 2011 at 19:16 Comment(0)
E
9

I've looked into most of these... I'd recommend looking into

Hammer.Js

From what little I've seen, it has support for both desktop and mobile swiping and I was impressed with the demos.

Eindhoven answered 2/3, 2013 at 22:53 Comment(0)
D
8

You'll want to handle onmousedown, onmousemove, and onmouseup events, keeping track of the mouse position and manipulating your image rotator accordingly.

Diver answered 25/10, 2011 at 19:16 Comment(0)
E
4

I believe you are looking for this answer: Standalone jQuery "touch" method?

The accepted answer has code to implement swipe left/right support and another answer lower down has a link to a plugin that does a similar task: http://www.netcu.de/jquery-touchwipe-iphone-ipad-library (this plugin allows detection of swipes in four directions).

Encaenia answered 25/10, 2011 at 19:21 Comment(0)
B
2

When you use Hammer.js, you also have support for touch/mouse and pointer events. This for touch screen laptops like the chromebook pixel and windows8. Most of the libraries out there dont support those yet.

Bogoch answered 8/3, 2013 at 15:59 Comment(0)
E
2

I ended up using iDangerous iSwiper, which met all my needs and is (IMO) very excellent.

Eindhoven answered 16/10, 2013 at 16:32 Comment(1)
Your link is a dead linkLustre

© 2022 - 2024 — McMap. All rights reserved.