-
-
Save grim-reapper/a425a1c9f9725710ea1822bb3861e0d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * jQuery Double Tap | |
| * Developer: Sergey Margaritov (github.com/attenzione) | |
| * License: MIT | |
| * Date: 22.10.2013 | |
| * Based on jquery documentation http://learn.jquery.com/events/event-extensions/ | |
| */ | |
| (function($){ | |
| $.event.special.doubletap = { | |
| bindType: 'touchend', | |
| delegateType: 'touchend', | |
| handle: function(event) { | |
| var handleObj = event.handleObj, | |
| targetData = jQuery.data(event.target), | |
| now = new Date().getTime(), | |
| delta = targetData.lastTouch ? now - targetData.lastTouch : 0, | |
| delay = delay == null ? 300 : delay; | |
| if (delta < delay && delta > 30) { | |
| targetData.lastTouch = null; | |
| event.type = handleObj.origType; | |
| ['clientX', 'clientY', 'pageX', 'pageY'].forEach(function(property) { | |
| event[property] = event.originalEvent.changedTouches[0][property]; | |
| }) | |
| // let jQuery handle the triggering of "doubletap" event handlers | |
| handleObj.handler.apply(this, arguments); | |
| } else { | |
| targetData.lastTouch = now; | |
| } | |
| } | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment