Those things on the mobile end; good jq plug-in for hammer ., Hammerjq

Source: Internet
Author: User

Those things on the mobile end; good jq plug-in for hammer ., Hammerjq

From the pc end to the mobile end, I believe that many front-end siege engineers are worried about the mobile end. It is very laborious to write the original audio on the mobile phone end, And the jq click has a latency of 300 milliseconds, now we have a good jq plug-in, hammer. javascript is an open-source and lightweight javascript library that can recognize the touch without relying on other things. mouse events support various mobile phone events, such as scaling and left-sliding qq deletion, zoom in and rotate.

 

Next we will use a tab switch to introduce hammer.

Usage:

 

1. First introduce jq2.0 and later versions and jquery. hammer. js.

2. Get the element. Just like jq, add hammer to the end and var hammertime = $ ('. tabs A'). hammer ();

3. You can directly add the event hammertime. on ('Tap ', function (ev) {} using the tap Click Event in hammer. Function can write your own js.

 

hammer.dragstart = function(ev) { };// Start dragging </span>

hammer.drag = function (ev) { }; // Dragging </span> hammer.dragend = function (ev) { }; // Drag the end </span> hammer.onswipe = function (ev) { }; // Slide </span>  hammer.tap = function (ev) { }; // Click </span> hammer.doubletap = function (ev) { }; // Double-click </span> hammer.hold = function (ev) { }; // Long press </span>  hammer.release = function (ev) { }; // Exit the screen with your fingers </span>

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

Js code

1 $ (function () {2 var hammertime = $ ('. tabs '). hammer (); 3 hammertime. on ('tap', function (ev) {4 $ (this ). addClass ('actives '). siblings (). removeClass ('actives'); // Add a class to remove at the same level. 5 var index = $ ('. tabs '). index (this); // index 6 $ ('. tab-bott '). eq (index ). show (). siblings (). hide (); 7}) 8 })

Recommended front-end Group: Group Name: html5/css3/js/jq/nodejs/div group number: 339840649 join the discussion.

Related Article

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.