This article introduces the jQuery plug-in Hammer on the Mobile End. js, an open-source and lightweight javascript library that can recognize touch without relying on other things. mouse events support various mobile phone events, such as scaling, qq left slide Delete, zoom in, rotate and so on from pc end to Mobile End believe that many front-end siege engineers worried about the mobile end, It is very laborious to write the original sound of mobile terminal events, the jq click has a latency of 300 milliseconds. Now we have a good jq plug-in hammer and 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 to drag hammer. drag = function (ev) {}; // drag hammer. dragend = function (ev) {}; // drag and end hammer. onswipe = function (ev) {}; // sliding hammer. tap = function (ev) {}; // click hammer. doubletap = function (ev) {}; // double-click hammer. hold = function (ev) {}; // long press hammer. release = function (ev) {}; // exit the screen with your finger
Experience link: http://hammerjs.github.io/
Js code
$ (Function () {var hammertime = $ ('. tabs '). hammer (); hammertime. on ('tap', function (ev) {$ (this ). addClass ('actives '). siblings (). removeClass ('actives'); // Add a class to remove at the same level. Var index = $ ('. tabs '). index (this); // index $ ('. tab-bott '). eq (index ). show (). siblings (). hide ();})})
The above is all the content of this article. I hope you will like it.