PageSourceSearch

https://mrperfectworld.com/lib/touchSwipe/jquery.touchSwipe.min.js

js mrperfectworld.com collected 2026-10-02 01:36:29 UTC 34,243 bytes, 1,034 lines download raw bytes

1/*!
2 * @fileOverview TouchSwipe - jQuery Plugin
3 * @version 1.6.18
4 *
5 * @author Matt Bryson https://www.github.com/mattbryson
6 * @see https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
7 * @see https://labs.rampinteractive.co.uk/touchSwipe/
8 * @see https://plugins.jquery.com/project/touchSwipe
9 * @license
10 * Copyright (c) 2010-2015 Matt Bryson
11 * Dual licensed under the MIT or GPL Version 2 licenses.
12 *
13 */
14!(function (factory) {
15  "function" == typeof define && define.amd && define.amd.jQuery
16    ? define(["jquery"], factory)
17    : factory(
18        "undefined" != typeof module && module.exports
19          ? require("jquery")
20          : jQuery
21      );
22})(function ($) {
23  "use strict";
24  function init(options) {
25    return (
26      !options ||
27        void 0 !== options.allowPageScroll ||
28        (void 0 === options.swipe && void 0 === options.swipeStatus) ||
29        (options.allowPageScroll = NONE),
30      void 0 !== options.click &&
31        void 0 === options.tap &&
32        (options.tap = options.click),
33      options || (options = {}),
34      (options = $.extend({}, $.fn.swipe.defaults, options)),
35      this.each(function () {
36        var $this = $(this),
37          plugin = $this.data(PLUGIN_NS);
38        plugin ||
39          ((plugin = new TouchSwipe(this, options)),
40          $this.data(PLUGIN_NS, plugin));
41      })
42    );
43  }
44  function TouchSwipe(element, options) {
45    function touchStart(jqEvent) {
46      if (
47        !(
48          getTouchInProgress() ||
49          $(jqEvent.target).closest(options.excludedElements, $element).length >
50            0
51        )
52      ) {
53        var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
54        if (
55          !event.pointerType ||
56          "mouse" != event.pointerType ||
57          0 != options.fallbackToMouseEvents
58        ) {
59          var ret,
60            touches = event.touches,
61            evt = touches ? touches[0] : event;
62          return (
63            (phase = PHASE_START),
64            touches
65              ? (fingerCount = touches.length)
66              : options.preventDefaultEvents !== !1 && jqEvent.preventDefault(),
67            (distance = 0),
68            (direction = null),
69            (currentDirection = null),
70            (pinchDirection = null),
71            (duration = 0),
72            (startTouchesDistance = 0),
73            (endTouchesDistance = 0),
74            (pinchZoom = 1),
75            (pinchDistance = 0),
76            (maximumsMap = createMaximumsData()),
77            cancelMultiFingerRelease(),
78            createFingerData(0, evt),
79            !touches ||
80            fingerCount === options.fingers ||
81            options.fingers === ALL_FINGERS ||
82            hasPinches()
83              ? ((startTime = getTimeStamp()),
84                2 == fingerCount &&
85                  (createFingerData(1, touches[1]),
86                  (startTouchesDistance = endTouchesDistance =
87                    calculateTouchesDistance(
88                      fingerData[0].start,
89                      fingerData[1].start
90                    ))),
91                (options.swipeStatus || options.pinchStatus) &&
92                  (ret = triggerHandler(event, phase)))
93              : (ret = !1),
94            ret === !1
95              ? ((phase = PHASE_CANCEL), triggerHandler(event, phase), ret)
96              : (options.hold &&
97                  (holdTimeout = setTimeout(
98                    $.proxy(function () {
99                      $element.trigger("hold", [event.target]),
100                        options.hold &&
101                          (ret = options.hold.call(
102                            $element,
103                            event,
104                            event.target
105                          ));
106                    }, this),
107                    options.longTapThreshold
108                  )),
109                setTouchInProgress(!0),
110                null)
111          );
112        }
113      }
114    }
115    function touchMove(jqEvent) {
116      var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
117      if (
118        phase !== PHASE_END &&
119        phase !== PHASE_CANCEL &&
120        !inMultiFingerRelease()
121      ) {
122        var ret,
123          touches = event.touches,
124          evt = touches ? touches[0] : event,
125          currentFinger = updateFingerData(evt);
126        if (
127          ((endTime = getTimeStamp()),
128          touches && (fingerCount = touches.length),
129          options.hold && clearTimeout(holdTimeout),
130          (phase = PHASE_MOVE),
131          2 == fingerCount &&
132            (0 == startTouchesDistance
133              ? (createFingerData(1, touches[1]),
134                (startTouchesDistance = endTouchesDistance =
135                  calculateTouchesDistance(
136                    fingerData[0].start,
137                    fingerData[1].start
138                  )))
139              : (updateFingerData(touches[1]),
140                (endTouchesDistance = calculateTouchesDistance(
141                  fingerData[0].end,
142                  fingerData[1].end
143                )),
144                (pinchDirection = calculatePinchDirection(
145                  fingerData[0].end,
146                  fingerData[1].end
147                ))),
148            (pinchZoom = calculatePinchZoom(
149              startTouchesDistance,
150              endTouchesDistance
151            )),
152            (pinchDistance = Math.abs(
153              startTouchesDistance - endTouchesDistance
154            ))),
155          fingerCount === options.fingers ||
156            options.fingers === ALL_FINGERS ||
157            !touches ||
158            hasPinches())
159        ) {
160          if (
161            ((direction = calculateDirection(
162              currentFinger.start,
163              currentFinger.end
164            )),
165            (currentDirection = calculateDirection(
166              currentFinger.last,
167              currentFinger.end
168            )),
169            validateDefaultEvent(jqEvent, currentDirection),
170            (distance = calculateDistance(
171              currentFinger.start,
172              currentFinger.end
173            )),
174            (duration = calculateDuration()),
175            setMaxDistance(direction, distance),
176            (ret = triggerHandler(event, phase)),
177            !options.triggerOnTouchEnd || options.triggerOnTouchLeave)
178          ) {
179            var inBounds = !0;
180            if (options.triggerOnTouchLeave) {
181              var bounds = getbounds(this);
182              inBounds = isInBounds(currentFinger.end, bounds);
183            }
184            !options.triggerOnTouchEnd && inBounds
185              ? (phase = getNextPhase(PHASE_MOVE))
186              : options.triggerOnTouchLeave &&
187                !inBounds &&
188                (phase = getNextPhase(PHASE_END)),
189              (phase != PHASE_CANCEL && phase != PHASE_END) ||
190                triggerHandler(event, phase);
191          }
192        } else (phase = PHASE_CANCEL), triggerHandler(event, phase);
193        ret === !1 && ((phase = PHASE_CANCEL), triggerHandler(event, phase));
194      }
195    }
196    function touchEnd(jqEvent) {
197      var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent,
198        touches = event.touches;
199      if (touches) {
200        if (touches.length && !inMultiFingerRelease())
201          return startMultiFingerRelease(event), !0;
202        if (touches.length && inMultiFingerRelease()) return !0;
203      }
204      return (
205        inMultiFingerRelease() && (fingerCount = fingerCountAtRelease),
206        (endTime = getTimeStamp()),
207        (duration = calculateDuration()),
208        didSwipeBackToCancel() || !validateSwipeDistance()
209          ? ((phase = PHASE_CANCEL), triggerHandler(event, phase))
210          : options.triggerOnTouchEnd ||
211            (options.triggerOnTouchEnd === !1 && phase === PHASE_MOVE)
212          ? (options.preventDefaultEvents !== !1 &&
213              jqEvent.cancelable !== !1 &&
214              jqEvent.preventDefault(),
215            (phase = PHASE_END),
216            triggerHandler(event, phase))
217          : !options.triggerOnTouchEnd && hasTap()
218          ? ((phase = PHASE_END), triggerHandlerForGesture(event, phase, TAP))
219          : phase === PHASE_MOVE &&
220            ((phase = PHASE_CANCEL), triggerHandler(event, phase)),
221        setTouchInProgress(!1),
222        null
223      );
224    }
225    function touchCancel() {
226      (fingerCount = 0),
227        (endTime = 0),
228        (startTime = 0),
229        (startTouchesDistance = 0),
230        (endTouchesDistance = 0),
231        (pinchZoom = 1),
232        cancelMultiFingerRelease(),
233        setTouchInProgress(!1);
234    }
235    function touchLeave(jqEvent) {
236      var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
237      options.triggerOnTouchLeave &&
238        ((phase = getNextPhase(PHASE_END)), triggerHandler(event, phase));
239    }
240    function removeListeners() {
241      $element.unbind(START_EV, touchStart),
242        $element.unbind(CANCEL_EV, touchCancel),
243        $element.unbind(MOVE_EV, touchMove),
244        $element.unbind(END_EV, touchEnd),
245        LEAVE_EV && $element.unbind(LEAVE_EV, touchLeave),
246        setTouchInProgress(!1);
247    }
248    function getNextPhase(currentPhase) {
249      var nextPhase = currentPhase,
250        validTime = validateSwipeTime(),
251        validDistance = validateSwipeDistance(),
252        didCancel = didSwipeBackToCancel();
253      return (
254        !validTime || didCancel
255          ? (nextPhase = PHASE_CANCEL)
256          : !validDistance ||
257            currentPhase != PHASE_MOVE ||
258            (options.triggerOnTouchEnd && !options.triggerOnTouchLeave)
259          ? !validDistance &&
260            currentPhase == PHASE_END &&
261            options.triggerOnTouchLeave &&
262            (nextPhase = PHASE_CANCEL)
263          : (nextPhase = PHASE_END),
264        nextPhase
265      );
266    }
267    function triggerHandler(event, phase) {
268      var ret,
269        touches = event.touches;
270      return (
271        (didSwipe() || hasSwipes()) &&
272          (ret = triggerHandlerForGesture(event, phase, SWIPE)),
273        (didPinch() || hasPinches()) &&
274          ret !== !1 &&
275          (ret = triggerHandlerForGesture(event, phase, PINCH)),
276        didDoubleTap() && ret !== !1
277          ? (ret = triggerHandlerForGesture(event, phase, DOUBLE_TAP))
278          : didLongTap() && ret !== !1
279          ? (ret = triggerHandlerForGesture(event, phase, LONG_TAP))
280          : didTap() &&
281            ret !== !1 &&
282            (ret = triggerHandlerForGesture(event, phase, TAP)),
283        phase === PHASE_CANCEL && touchCancel(event),
284        phase === PHASE_END &&
285          (touches ? touches.length || touchCancel(event) : touchCancel(event)),
286        ret
287      );
288    }
289    function triggerHandlerForGesture(event, phase, gesture) {
290      var ret;
291      if (gesture == SWIPE) {
292        if (
293          ($element.trigger("swipeStatus", [
294            phase,
295            direction || null,
296            distance || 0,
297            duration || 0,
298            fingerCount,
299            fingerData,
300            currentDirection,
301          ]),
302          options.swipeStatus &&
303            ((ret = options.swipeStatus.call(
304              $element,
305              event,
306              phase,
307              direction || null,
308              distance || 0,
309              duration || 0,
310              fingerCount,
311              fingerData,
312              currentDirection
313            )),
314            ret === !1))
315        )
316          return !1;
317        if (phase == PHASE_END && validateSwipe()) {
318          if (
319            (clearTimeout(singleTapTimeout),
320            clearTimeout(holdTimeout),
321            $element.trigger("swipe", [
322              direction,
323              distance,
324              duration,
325              fingerCount,
326              fingerData,
327              currentDirection,
328            ]),
329            options.swipe &&
330              ((ret = options.swipe.call(
331                $element,
332                event,
333                direction,
334                distance,
335                duration,
336                fingerCount,
337                fingerData,
338                currentDirection
339              )),
340              ret === !1))
341          )
342            return !1;
343          switch (direction) {
344            case LEFT:
345              $element.trigger("swipeLeft", [
346                direction,
347                distance,
348                duration,
349                fingerCount,
350                fingerData,
351                currentDirection,
352              ]),
353                options.swipeLeft &&
354                  (ret = options.swipeLeft.call(
355                    $element,
356                    event,
357                    direction,
358                    distance,
359                    duration,
360                    fingerCount,
361                    fingerData,
362                    currentDirection
363                  ));
364              break;
365            case RIGHT:
366              $element.trigger("swipeRight", [
367                direction,
368                distance,
369                duration,
370                fingerCount,
371                fingerData,
372                currentDirection,
373              ]),
374                options.swipeRight &&
375                  (ret = options.swipeRight.call(
376                    $element,
377                    event,
378                    direction,
379                    distance,
380                    duration,
381                    fingerCount,
382                    fingerData,
383                    currentDirection
384                  ));
385              break;
386            case UP:
387              $element.trigger("swipeUp", [
388                direction,
389                distance,
390                duration,
391                fingerCount,
392                fingerData,
393                currentDirection,
394              ]),
395                options.swipeUp &&
396                  (ret = options.swipeUp.call(
397                    $element,
398                    event,
399                    direction,
400                    distance,
401                    duration,
402                    fingerCount,
403                    fingerData,
404                    currentDirection
405                  ));
406              break;
407            case DOWN:
408              $element.trigger("swipeDown", [
409                direction,
410                distance,
411                duration,
412                fingerCount,
413                fingerData,
414                currentDirection,
415              ]),
416                options.swipeDown &&
417                  (ret = options.swipeDown.call(
418                    $element,
419                    event,
420                    direction,
421                    distance,
422                    duration,
423                    fingerCount,
424                    fingerData,
425                    currentDirection
426                  ));
427          }
428        }
429      }
430      if (gesture == PINCH) {
431        if (
432          ($element.trigger("pinchStatus", [
433            phase,
434            pinchDirection || null,
435            pinchDistance || 0,
436            duration || 0,
437            fingerCount,
438            pinchZoom,
439            fingerData,
440          ]),
441          options.pinchStatus &&
442            ((ret = options.pinchStatus.call(
443              $element,
444              event,
445              phase,
446              pinchDirection || null,
447              pinchDistance || 0,
448              duration || 0,
449              fingerCount,
450              pinchZoom,
451              fingerData
452            )),
453            ret === !1))
454        )
455          return !1;
456        if (phase == PHASE_END && validatePinch())
457          switch (pinchDirection) {
458            case IN:
459              $element.trigger("pinchIn", [
460                pinchDirection || null,
461                pinchDistance || 0,
462                duration || 0,
463                fingerCount,
464                pinchZoom,
465                fingerData,
466              ]),
467                options.pinchIn &&
468                  (ret = options.pinchIn.call(
469                    $element,
470                    event,
471                    pinchDirection || null,
472                    pinchDistance || 0,
473                    duration || 0,
474                    fingerCount,
475                    pinchZoom,
476                    fingerData
477                  ));
478              break;
479            case OUT:
480              $element.trigger("pinchOut", [
481                pinchDirection || null,
482                pinchDistance || 0,
483                duration || 0,
484                fingerCount,
485                pinchZoom,
486                fingerData,
487              ]),
488                options.pinchOut &&
489                  (ret = options.pinchOut.call(
490                    $element,
491                    event,
492                    pinchDirection || null,
493                    pinchDistance || 0,
494                    duration || 0,
495                    fingerCount,
496                    pinchZoom,
497                    fingerData
498                  ));
499          }
500      }
501      return (
502        gesture == TAP
503          ? (phase !== PHASE_CANCEL && phase !== PHASE_END) ||
504            (clearTimeout(singleTapTimeout),
505            clearTimeout(holdTimeout),
506            hasDoubleTap() && !inDoubleTap()
507              ? ((doubleTapStartTime = getTimeStamp()),
508                (singleTapTimeout = setTimeout(
509                  $.proxy(function () {
510                    (doubleTapStartTime = null),
511                      $element.trigger("tap", [event.target]),
512                      options.tap &&
513                        (ret = options.tap.call($element, event, event.target));
514                  }, this),
515                  options.doubleTapThreshold
516                )))
517              : ((doubleTapStartTime = null),
518                $element.trigger("tap", [event.target]),
519                options.tap &&
520                  (ret = options.tap.call($element, event, event.target))))
521          : gesture == DOUBLE_TAP
522          ? (phase !== PHASE_CANCEL && phase !== PHASE_END) ||
523            (clearTimeout(singleTapTimeout),
524            clearTimeout(holdTimeout),
525            (doubleTapStartTime = null),
526            $element.trigger("doubletap", [event.target]),
527            options.doubleTap &&
528              (ret = options.doubleTap.call($element, event, event.target)))
529          : gesture == LONG_TAP &&
530            ((phase !== PHASE_CANCEL && phase !== PHASE_END) ||
531              (clearTimeout(singleTapTimeout),
532              (doubleTapStartTime = null),
533              $element.trigger("longtap", [event.target]),
534              options.longTap &&
535                (ret = options.longTap.call($element, event, event.target)))),
536        ret
537      );
538    }
539    function validateSwipeDistance() {
540      var valid = !0;
541      return (
542        null !== options.threshold && (valid = distance >= options.threshold),
543        valid
544      );
545    }
546    function didSwipeBackToCancel() {
547      var cancelled = !1;
548      return (
549        null !== options.cancelThreshold &&
550          null !== direction &&
551          (cancelled =
552            getMaxDistance(direction) - distance >= options.cancelThreshold),
553        cancelled
554      );
555    }
556    function validatePinchDistance() {
557      return (
558        null === options.pinchThreshold ||
559        pinchDistance >= options.pinchThreshold
560      );
561    }
562    function validateSwipeTime() {
563      var result;
564      return (result =
565        !options.maxTimeThreshold || !(duration >= options.maxTimeThreshold));
566    }
567    function validateDefaultEvent(jqEvent, direction) {
568      if (options.preventDefaultEvents !== !1)
569        if (options.allowPageScroll === NONE) jqEvent.preventDefault();
570        else {
571          var auto = options.allowPageScroll === AUTO;
572          switch (direction) {
573            case LEFT:
574              ((options.swipeLeft && auto) ||
575                (!auto && options.allowPageScroll != HORIZONTAL)) &&
576                jqEvent.preventDefault();
577              break;
578            case RIGHT:
579              ((options.swipeRight && auto) ||
580                (!auto && options.allowPageScroll != HORIZONTAL)) &&
581                jqEvent.preventDefault();
582              break;
583            case UP:
584              ((options.swipeUp && auto) ||
585                (!auto && options.allowPageScroll != VERTICAL)) &&
586                jqEvent.preventDefault();
587              break;
588            case DOWN:
589              ((options.swipeDown && auto) ||
590                (!auto && options.allowPageScroll != VERTICAL)) &&
591                jqEvent.preventDefault();
592              break;
593            case NONE:
594          }
595        }
596    }
597    function validatePinch() {
598      var hasCorrectFingerCount = validateFingers(),
599        hasEndPoint = validateEndPoint(),
600        hasCorrectDistance = validatePinchDistance();
601      return hasCorrectFingerCount && hasEndPoint && hasCorrectDistance;
602    }
603    function hasPinches() {
604      return !!(options.pinchStatus || options.pinchIn || options.pinchOut);
605    }
606    function didPinch() {
607      return !(!validatePinch() || !hasPinches());
608    }
609    function validateSwipe() {
610      var hasValidTime = validateSwipeTime(),
611        hasValidDistance = validateSwipeDistance(),
612        hasCorrectFingerCount = validateFingers(),
613        hasEndPoint = validateEndPoint(),
614        didCancel = didSwipeBackToCancel(),
615        valid =
616          !didCancel &&
617          hasEndPoint &&
618          hasCorrectFingerCount &&
619          hasValidDistance &&
620          hasValidTime;
621      return valid;
622    }
623    function hasSwipes() {
624      return !!(
625        options.swipe ||
626        options.swipeStatus ||
627        options.swipeLeft ||
628        options.swipeRight ||
629        options.swipeUp ||
630        options.swipeDown
631      );
632    }
633    function didSwipe() {
634      return !(!validateSwipe() || !hasSwipes());
635    }
636    function validateFingers() {
637      return (
638        fingerCount === options.fingers ||
639        options.fingers === ALL_FINGERS ||
640        !SUPPORTS_TOUCH
641      );
642    }
643    function validateEndPoint() {
644      return 0 !== fingerData[0].end.x;
645    }
646    function hasTap() {
647      return !!options.tap;
648    }
649    function hasDoubleTap() {
650      return !!options.doubleTap;
651    }
652    function hasLongTap() {
653      return !!options.longTap;
654    }
655    function validateDoubleTap() {
656      if (null == doubleTapStartTime) return !1;
657      var now = getTimeStamp();
658      return (
659        hasDoubleTap() && now - doubleTapStartTime <= options.doubleTapThreshold
660      );
661    }
662    function inDoubleTap() {
663      return validateDoubleTap();
664    }
665    function validateTap() {
666      return (
667        (1 === fingerCount || !SUPPORTS_TOUCH) &&
668        (isNaN(distance) || distance < options.threshold)
669      );
670    }
671    function validateLongTap() {
672      return (
673        duration > options.longTapThreshold && distance < DOUBLE_TAP_THRESHOLD
674      );
675    }
676    function didTap() {
677      return !(!validateTap() || !hasTap());
678    }
679    function didDoubleTap() {
680      return !(!validateDoubleTap() || !hasDoubleTap());
681    }
682    function didLongTap() {
683      return !(!validateLongTap() || !hasLongTap());
684    }
685    function startMultiFingerRelease(event) {
686      (previousTouchEndTime = getTimeStamp()),
687        (fingerCountAtRelease = event.touches.length + 1);
688    }
689    function cancelMultiFingerRelease() {
690      (previousTouchEndTime = 0), (fingerCountAtRelease = 0);
691    }
692    function inMultiFingerRelease() {
693      var withinThreshold = !1;
694      if (previousTouchEndTime) {
695        var diff = getTimeStamp() - previousTouchEndTime;
696        diff <= options.fingerReleaseThreshold && (withinThreshold = !0);
697      }
698      return withinThreshold;
699    }
700    function getTouchInProgress() {
701      return !($element.data(PLUGIN_NS + "_intouch") !== !0);
702    }
703    function setTouchInProgress(val) {
704      $element &&
705        (val === !0
706          ? ($element.bind(MOVE_EV, touchMove),
707            $element.bind(END_EV, touchEnd),
708            LEAVE_EV && $element.bind(LEAVE_EV, touchLeave))
709          : ($element.unbind(MOVE_EV, touchMove, !1),
710            $element.unbind(END_EV, touchEnd, !1),
711            LEAVE_EV && $element.unbind(LEAVE_EV, touchLeave, !1)),
712        $element.data(PLUGIN_NS + "_intouch", val === !0));
713    }
714    function createFingerData(id, evt) {
715      var f = {
716        start: { x: 0, y: 0 },
717        last: { x: 0, y: 0 },
718        end: { x: 0, y: 0 },
719      };
720      return (
721        (f.start.x = f.last.x = f.end.x = evt.pageX || evt.clientX),
722        (f.start.y = f.last.y = f.end.y = evt.pageY || evt.clientY),
723        (fingerData[id] = f),
724        f
725      );
726    }
727    function updateFingerData(evt) {
728      var id = void 0 !== evt.identifier ? evt.identifier : 0,
729        f = getFingerData(id);
730      return (
731        null === f && (f = createFingerData(id, evt)),
732        (f.last.x = f.end.x),
733        (f.last.y = f.end.y),
734        (f.end.x = evt.pageX || evt.clientX),
735        (f.end.y = evt.pageY || evt.clientY),
736        f
737      );
738    }
739    function getFingerData(id) {
740      return fingerData[id] || null;
741    }
742    function setMaxDistance(direction, distance) {
743      direction != NONE &&
744        ((distance = Math.max(distance, getMaxDistance(direction))),
745        (maximumsMap[direction].distance = distance));
746    }
747    function getMaxDistance(direction) {
748      if (maximumsMap[direction]) return maximumsMap[direction].distance;
749    }
750    function createMaximumsData() {
751      var maxData = {};
752      return (
753        (maxData[LEFT] = createMaximumVO(LEFT)),
754        (maxData[RIGHT] = createMaximumVO(RIGHT)),
755        (maxData[UP] = createMaximumVO(UP)),
756        (maxData[DOWN] = createMaximumVO(DOWN)),
757        maxData
758      );
759    }
760    function createMaximumVO(dir) {
761      return { direction: dir, distance: 0 };
762    }
763    function calculateDuration() {
764      return endTime - startTime;
765    }
766    function calculateTouchesDistance(startPoint, endPoint) {
767      var diffX = Math.abs(startPoint.x - endPoint.x),
768        diffY = Math.abs(startPoint.y - endPoint.y);
769      return Math.round(Math.sqrt(diffX * diffX + diffY * diffY));
770    }
771    function calculatePinchZoom(startDistance, endDistance) {
772      var percent = (endDistance / startDistance) * 1;
773      return percent.toFixed(2);
774    }
775    function calculatePinchDirection() {
776      return pinchZoom < 1 ? OUT : IN;
777    }
778    function calculateDistance(startPoint, endPoint) {
779      return Math.round(
780        Math.sqrt(
781          Math.pow(endPoint.x - startPoint.x, 2) +
782            Math.pow(endPoint.y - startPoint.y, 2)
783        )
784      );
785    }
786    function calculateAngle(startPoint, endPoint) {
787      var x = startPoint.x - endPoint.x,
788        y = endPoint.y - startPoint.y,
789        r = Math.atan2(y, x),
790        angle = Math.round((180 * r) / Math.PI);
791      return angle < 0 && (angle = 360 - Math.abs(angle)), angle;
792    }
793    function calculateDirection(startPoint, endPoint) {
794      if (comparePoints(startPoint, endPoint)) return NONE;
795      var angle = calculateAngle(startPoint, endPoint);
796      return angle <= 45 && angle >= 0
797        ? LEFT
798        : angle <= 360 && angle >= 315
799        ? LEFT
800        : angle >= 135 && angle <= 225
801        ? RIGHT
802        : angle > 45 && angle < 135
803        ? DOWN
804        : UP;
805    }
806    function getTimeStamp() {
807      var now = new Date();
808      return now.getTime();
809    }
810    function getbounds(el) {
811      el = $(el);
812      var offset = el.offset(),
813        bounds = {
814          left: offset.left,
815          right: offset.left + el.outerWidth(),
816          top: offset.top,
817          bottom: offset.top + el.outerHeight(),
818        };
819      return bounds;
820    }
821    function isInBounds(point, bounds) {
822      return (
823        point.x > bounds.left &&
824        point.x < bounds.right &&
825        point.y > bounds.top &&
826        point.y < bounds.bottom
827      );
828    }
829    function comparePoints(pointA, pointB) {
830      return pointA.x == pointB.x && pointA.y == pointB.y;
831    }
832    var options = $.extend({}, options),
833      useTouchEvents =
834        SUPPORTS_TOUCH || SUPPORTS_POINTER || !options.fallbackToMouseEvents,
835      START_EV = useTouchEvents
836        ? SUPPORTS_POINTER
837          ? SUPPORTS_POINTER_IE10
838            ? "MSPointerDown"
839            : "pointerdown"
840          : "touchstart"
841        : "mousedown",
842      MOVE_EV = useTouchEvents
843        ? SUPPORTS_POINTER
844          ? SUPPORTS_POINTER_IE10
845            ? "MSPointerMove"
846            : "pointermove"
847          : "touchmove"
848        : "mousemove",
849      END_EV = useTouchEvents
850        ? SUPPORTS_POINTER
851          ? SUPPORTS_POINTER_IE10
852            ? "MSPointerUp"
853            : "pointerup"
854          : "touchend"
855        : "mouseup",
856      LEAVE_EV = useTouchEvents
857        ? SUPPORTS_POINTER
858          ? "mouseleave"
859          : null
860        : "mouseleave",
861      CANCEL_EV = SUPPORTS_POINTER
862        ? SUPPORTS_POINTER_IE10
863          ? "MSPointerCancel"
864          : "pointercancel"
865        : "touchcancel",
866      distance = 0,
867      direction = null,
868      currentDirection = null,
869      duration = 0,
870      startTouchesDistance = 0,
871      endTouchesDistance = 0,
872      pinchZoom = 1,
873      pinchDistance = 0,
874      pinchDirection = 0,
875      maximumsMap = null,
876      $element = $(element),
877      phase = "start",
878      fingerCount = 0,
879      fingerData = {},
880      startTime = 0,
881      endTime = 0,
882      previousTouchEndTime = 0,
883      fingerCountAtRelease = 0,
884      doubleTapStartTime = 0,
885      singleTapTimeout = null,
886      holdTimeout = null;
887    try {
888      $element.bind(START_EV, touchStart),
889        $element.bind(CANCEL_EV, touchCancel);
890    } catch (e) {
891      $.error(
892        "events not supported " +
893          START_EV +
894          "," +
895          CANCEL_EV +
896          " on jQuery.swipe"
897      );
898    }
899    (this.enable = function () {
900      return (
901        this.disable(),
902        $element.bind(START_EV, touchStart),
903        $element.bind(CANCEL_EV, touchCancel),
904        $element
905      );
906    }),
907      (this.disable = function () {
908        return removeListeners(), $element;
909      }),
910      (this.destroy = function () {
911        removeListeners(), $element.data(PLUGIN_NS, null), ($element = null);
912      }),
913      (this.option = function (property, value) {
914        if ("object" == typeof property) options = $.extend(options, property);
915        else if (void 0 !== options[property]) {
916          if (void 0 === value) return options[property];
917          options[property] = value;
918        } else {
919          if (!property) return options;
920          $.error(
921            "Option " + property + " does not exist on jQuery.swipe.options"
922          );
923        }
924        return null;
925      });
926  }
927  var VERSION = "1.6.18",
928    LEFT = "left",
929    RIGHT = "right",
930    UP = "up",
931    DOWN = "down",
932    IN = "in",
933    OUT = "out",
934    NONE = "none",
935    AUTO = "auto",
936    SWIPE = "swipe",
937    PINCH = "pinch",
938    TAP = "tap",
939    DOUBLE_TAP = "doubletap",
940    LONG_TAP = "longtap",
941    HORIZONTAL = "horizontal",
942    VERTICAL = "vertical",
943    ALL_FINGERS = "all",
944    DOUBLE_TAP_THRESHOLD = 10,
945    PHASE_START = "start",
946    PHASE_MOVE = "move",
947    PHASE_END = "end",
948    PHASE_CANCEL = "cancel",
949    SUPPORTS_TOUCH = "ontouchstart" in window,
950    SUPPORTS_POINTER_IE10 =
951      window.navigator.msPointerEnabled &&
952      !window.navigator.pointerEnabled &&
953      !SUPPORTS_TOUCH,
954    SUPPORTS_POINTER =
955      (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) &&
956      !SUPPORTS_TOUCH,
957    PLUGIN_NS = "TouchSwipe",
958    defaults = {
959      fingers: 1,
960      threshold: 75,
961      cancelThreshold: null,
962      pinchThreshold: 20,
963      maxTimeThreshold: null,
964      fingerReleaseThreshold: 250,
965      longTapThreshold: 500,
966      doubleTapThreshold: 200,
967      swipe: null,
968      swipeLeft: null,
969      swipeRight: null,
970      swipeUp: null,
971      swipeDown: null,
972      swipeStatus: null,
973      pinchIn: null,
974      pinchOut: null,
975      pinchStatus: null,
976      click: null,
977      tap: null,
978      doubleTap: null,
979      longTap: null,
980      hold: null,
981      triggerOnTouchEnd: !0,
982      triggerOnTouchLeave: !1,
983      allowPageScroll: "auto",
984      fallbackToMouseEvents: !0,
985      excludedElements: ".noSwipe",
986      preventDefaultEvents: !0,
987    };
988  ($.fn.swipe = function (method) {
989    var $this = $(this),
990      plugin = $this.data(PLUGIN_NS);
991    if (plugin && "string" == typeof method) {
992      if (plugin[method])
993        return plugin[method].apply(
994          plugin,
995          Array.prototype.slice.call(arguments, 1)
996        );
997      $.error("Method " + method + " does not exist on jQuery.swipe");
998    } else if (plugin && "object" == typeof method)
999      plugin.option.apply(plugin, arguments);
1000    else if (!(plugin || ("object" != typeof method && method)))
1001      return init.apply(this, arguments);
1002    return $this;
1003  }),
1004    ($.fn.swipe.version = VERSION),
1005    ($.fn.swipe.defaults = defaults),
1006    ($.fn.swipe.phases = {
1007      PHASE_START: PHASE_START,
1008      PHASE_MOVE: PHASE_MOVE,
1009      PHASE_END: PHASE_END,
1010      PHASE_CANCEL: PHASE_CANCEL,
1011    }),
1012    ($.fn.swipe.directions = {
1013      LEFT: LEFT,
1014      RIGHT: RIGHT,
1015      UP: UP,
1016      DOWN: DOWN,
1017      IN: IN,
1018      OUT: OUT,
1019    }),
1020    ($.fn.swipe.pageScroll = {
1021      NONE: NONE,
1022      HORIZONTAL: HORIZONTAL,
1023      VERTICAL: VERTICAL,
1024      AUTO: AUTO,
1025    }),
1026    ($.fn.swipe.fingers = {
1027      ONE: 1,
1028      TWO: 2,
1029      THREE: 3,
1030      FOUR: 4,
1031      FIVE: 5,
1032      ALL: ALL_FINGERS,
1033    });
1034});

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.