JQuery. event. swipe plugin supports gesture operation slides

Source: Internet
Author: User

JQuery. event. swipe is a Jquery plug-in that allows slide to support gesture operations. It can customize touch events and prevent browser click events. It is of great help for image display slide development in mobile development, A lightweight JavaScript plug-in library.


JQuery. event. swipe: Jquery plug-in that allows slide to support gesture operations

Project

Github: github.com/stephen band/jquery.event.swipe
Issues: github.com/stephen band/jquery.event.swipe/issues
Dependency: github.com/stephen band/jquery.event.move

Swipe event

Swipeleft, swiperight, swipeup, swipedown
The finger is released from the contact surface (or the middle mouse button) if the finger has at least a short distance from the threshold or B) quickly. Also responds to the mouse.
Addition and performance of Swipe event objects:
E. pageX, e. pageY
The coordinates of the current page.
E. startX, e. startY
The pointer of the page coordinate starts sliding.
E. distX, e. distY
Finger movement distance
E. velocityX, e. velocityY
Speed, in pixels/MS, past several moving average events.
How to use

Var slides = jQuery ('. slides '),
I = 0;
Slides
. On ('swipeleft ', function (e ){
Slides. eq (I + 1). addClass ('active ');
})
. On ('swiperight ', function (e ){
Slides. eq (I-1). addClass ('active ');
});

The Swipe event in the MoveEnd event is thin packed; easy to reveal when the finger moves in the sliding gesture. Bottom-layer mobile event bubbles can represent them, but doing so with the Swipe event will lead to unnecessary expensive. Use Mobile events if you need more.
Slide or scroll
The Swipe event thin packaging is built on the Move Event (Stephen band.info/jquery.event.move ). By default, move events overwrite local scrolling because they recognize what you want to move instead of rolling the window to re-enable scrolling. Call e. preventDefault () inside a MoveStart processor.
In the above example, we want to be able to swipeleft and swiperight, but scroll up and down. In the processing direction of MoveStart, if the finger moves computing and event prevention is found to move or:

JQuery ('. mydiv ')
. On ('movestart', function (e ){
// If the movestart is heading off in an upwards or downwards
// Direction, prevent it so that the browser scrolls normally.
If (e. distX> e. distY & e. distX <-e. distY) |
(E. distX <e. distY & e. distX>-e. distY )){
E. preventDefault ();
  }
});
On the top of the page, view the source code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.