Mobile End JQ Plugin Hammer use detailed _jquery

Source: Internet
Author: User

From the PC end to the mobile end to believe that many front-end siege to the mobile end, write the original soundtrack of the phone-side event is very laborious, and JQ Click has 300 milliseconds delay, now has a relatively good JQ plug-in hammer, Hammer.js is an open source, lightweight JavaScript library, it can be no need to rely on other things to identify the touch, mouse events to support a variety of mobile phone events, such as scaling, QQ left sliding delete, magnification, rotation and so on.

The following is a tab switch to introduce hammer.

Usage:

1, first introduce jq2.0 above version and Jquery.hammer.js.

2, get the element, same as JQ, add hammer at the back to the var Hammertime = $ ('. Tabs a '). Hammer ();

3, you can add event Hammertime.on (' Tap ', function (EV) {}) directly with on to use the tap-click event in Hammer. function can write their own JS.

Hammer.dragstart = function (EV) {};//start dragging </span>

Hammer.drag = function (ev) {};//drag in </span>
Hamm Er.dragend = function (ev) {}; Drag end </span>
hammer.onswipe = function (ev) {};//sliding </span>
 
Hammer.tap = function (ev) {};//click ;/span>
Hammer.doubletap = function (EV) {}//double-click </span>
hammer.hold = function (EV) {};//long press </span& gt;
 
Hammer.release = function (ev) {}; Finger off Screen </span>

Experience Link: http://hammerjs.github.io/

JS Code

$ (function () {
var hammertime = $ ('. Tabs a '). Hammer ();
Hammertime.on (' Tap ', function (EV) {
$ (this). addclass (' actives '). Siblings (). Removeclass (' actives '); Adds a class-sibling removal.  
var index = $ ('. Tabs a '). Index (this),//Index
$ ('. Tab-bott '). EQ (index). Show (). siblings (). Hide (); 
})
})

The above mentioned is the entire content of this article, I hope you can enjoy.

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.