vendor: 2,327 bytes, lines 1-85
1/** 2 * jquery.detectSwipe v2.1.3 3 * jQuery Plugin to obtain touch gestures from iPhone, iPod Touch, iPad and Android 4 * http://github.com/marcandre/detect_swipe 5 * Based on touchwipe by Andreas Waltl, netCU Internetagentur (http://www.netcu.de) 6 */ 7 8(function (factory) { 9 if (typeof define === 'function' && define.amd) { 10 // AMD. Register as an anonymous module. 11 define(['jquery'], factory); 12 } else if (typeof exports === 'object') { 13 // Node/CommonJS 14 module.exports = factory(require('jquery')); 15 } else { 16 // Browser globals 17 factory(jQuery); 18 } 19}(function($) { 20 21 $.detectSwipe = { 22 version: '2.1.2', 23 enabled: 'ontouchstart' in document.documentElement, 24 preventDefault: true, 25 threshold: 20 26 }; 27 28 var startX, 29 startY, 30 isMoving = false; 31 32 function onTouchEnd() { 33 this.removeEventListener('touchmove', onTouchMove); 34 this.removeEventListener('touchend', onTouchEnd); 35 isMoving = false; 36 } 37 38 function onTouchMove(e) { 39 if ($.detectSwipe.preventDefault) { e.preventDefault(); } 40 if(isMoving) { 41 var x = e.touches[0].pageX; 42 var y = e.touches[0].pageY; 43 var dx = startX - x; 44 var dy = startY - y; 45 var dir; 46 var ratio = window.devicePixelRatio || 1; 47 if(Math.abs(dx) * ratio >= $.detectSwipe.threshold) { 48 dir = dx > 0 ? 'left' : 'right' 49 } 50 else if(Math.abs(dy) * ratio >= $.detectSwipe.threshold) { 51 dir = dy > 0 ? 'up' : 'down' 52 } 53 if(dir) { 54 onTouchEnd.call(this); 55 $(this).trigger('swipe', dir).trigger('swipe' + dir); 56 } 57 } 58 } 59 60 function onTouchStart(e) { 61 if (e.touches.length == 1) { 62 startX = e.touches[0].pageX; 63 startY = e.touches[0].pageY; 64 isMoving = true; 65 this.addEventListener('touchmove', onTouchMove, false); 66 this.addEventListener('touchend', onTouchEnd, false); 67 } 68 } 69 70 function setup() { 71 this.addEventListener && this.addEventListener('touchstart', onTouchStart, false); 72 } 73 74 function teardown() { 75 this.removeEventListener('touchstart', onTouchStart); 76 } 77 78 $.event.special.swipe = { setup: setup }; 79 80 $.each(['left', 'up', 'down', 'right'], function () { 81 $.event.special['swipe' + this] = { setup: function(){ 82 $(this).on('swipe', $.noop); 83 } }; 84 }); 85}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.