hammerjs-rails 0.3.0 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45866f46e5fbe0c0cf29842a8a6a19dba8735fb3
4
- data.tar.gz: 396788421354d38e46e5b097540d68f511bb55d6
3
+ metadata.gz: 61113979a344fb203996e65b0490468408a3bde1
4
+ data.tar.gz: 67c20f4d81ac518018be012dc6710d7d5699fbe8
5
5
  SHA512:
6
- metadata.gz: 8e3f603f3a60819e93b6237bfccbed7350a3137d4bc810f9be81d71b5775a442088b21b5ef2015a006617480d3f1ea7ca7baf199e3f2a1d0f5dbe5a28f598e7c
7
- data.tar.gz: 4ac1e99b9b8e3baafb0c009f16f7dd50935b26eb819a77702dbc16c503f9e52016b279639ffdce2b5f8199aa6fe757c8a8a47e2f491b9974f1a7c0e6f5d66472
6
+ metadata.gz: 260e81aea505e453e3312beb4c52a374537649a3bad52b44cb954c7aef54a284efa202d91c9cae929cc9a8179487db51a3d841360ada209fae938ff56ec4bd29
7
+ data.tar.gz: 96fbe421bd7128d2c3e0e99e33d3822764265196a96f92284e8687cf5e5c9c99eba35608679ee1cc29a37b170811aa6cc504730552a33e04bbdd72c672191fdf
@@ -1,5 +1,5 @@
1
1
  module Hammerjs
2
2
  module Rails
3
- VERSION = '0.3.0'
3
+ VERSION = '2.0.4'
4
4
  end
5
- end
5
+ end
@@ -1,11 +1,15 @@
1
- (function(window, undefined) {
1
+ /*! Hammer.JS - v2.0.4 - 2014-09-28
2
+ * http://hammerjs.github.io/
3
+ *
4
+ * Copyright (c) 2014 Jorik Tangelder;
5
+ * Licensed under the MIT license */
6
+ (function(window, document, exportName, undefined) {
2
7
  'use strict';
3
8
 
4
9
  var VENDOR_PREFIXES = ['', 'webkit', 'moz', 'MS', 'ms', 'o'];
5
10
  var TEST_ELEMENT = document.createElement('div');
6
11
 
7
12
  var TYPE_FUNCTION = 'function';
8
- var TYPE_UNDEFINED = 'undefined';
9
13
 
10
14
  var round = Math.round;
11
15
  var abs = Math.abs;
@@ -18,7 +22,7 @@ var now = Date.now;
18
22
  * @param {Object} context
19
23
  * @returns {number}
20
24
  */
21
- function setTimeoutScope(fn, timeout, context) {
25
+ function setTimeoutContext(fn, timeout, context) {
22
26
  return setTimeout(bindFn(fn, context), timeout);
23
27
  }
24
28
 
@@ -46,7 +50,7 @@ function invokeArrayArg(arg, fn, context) {
46
50
  * @param {Object} context
47
51
  */
48
52
  function each(obj, iterator, context) {
49
- var i, len;
53
+ var i;
50
54
 
51
55
  if (!obj) {
52
56
  return;
@@ -55,8 +59,10 @@ function each(obj, iterator, context) {
55
59
  if (obj.forEach) {
56
60
  obj.forEach(iterator, context);
57
61
  } else if (obj.length !== undefined) {
58
- for (i = 0, len = obj.length; i < len; i++) {
62
+ i = 0;
63
+ while (i < obj.length) {
59
64
  iterator.call(context, obj[i], i, obj);
65
+ i++;
60
66
  }
61
67
  } else {
62
68
  for (i in obj) {
@@ -75,10 +81,12 @@ function each(obj, iterator, context) {
75
81
  */
76
82
  function extend(dest, src, merge) {
77
83
  var keys = Object.keys(src);
78
- for (var i = 0, len = keys.length; i < len; i++) {
84
+ var i = 0;
85
+ while (i < keys.length) {
79
86
  if (!merge || (merge && dest[keys[i]] === undefined)) {
80
87
  dest[keys[i]] = src[keys[i]];
81
88
  }
89
+ i++;
82
90
  }
83
91
  return dest;
84
92
  }
@@ -120,7 +128,7 @@ function inherit(child, base, properties) {
120
128
  * @returns {Function}
121
129
  */
122
130
  function bindFn(fn, context) {
123
- return function() {
131
+ return function boundFn() {
124
132
  return fn.apply(context, arguments);
125
133
  };
126
134
  }
@@ -151,25 +159,25 @@ function ifUndefined(val1, val2) {
151
159
 
152
160
  /**
153
161
  * addEventListener with multiple events at once
154
- * @param {HTMLElement} element
162
+ * @param {EventTarget} target
155
163
  * @param {String} types
156
164
  * @param {Function} handler
157
165
  */
158
- function addEventListeners(element, types, handler) {
166
+ function addEventListeners(target, types, handler) {
159
167
  each(splitStr(types), function(type) {
160
- element.addEventListener(type, handler, false);
168
+ target.addEventListener(type, handler, false);
161
169
  });
162
170
  }
163
171
 
164
172
  /**
165
173
  * removeEventListener with multiple events at once
166
- * @param {HTMLElement} element
174
+ * @param {EventTarget} target
167
175
  * @param {String} types
168
176
  * @param {Function} handler
169
177
  */
170
- function removeEventListeners(element, types, handler) {
178
+ function removeEventListeners(target, types, handler) {
171
179
  each(splitStr(types), function(type) {
172
- element.removeEventListener(type, handler, false);
180
+ target.removeEventListener(type, handler, false);
173
181
  });
174
182
  }
175
183
 
@@ -220,10 +228,12 @@ function inArray(src, find, findByKey) {
220
228
  if (src.indexOf && !findByKey) {
221
229
  return src.indexOf(find);
222
230
  } else {
223
- for (var i = 0, len = src.length; i < len; i++) {
231
+ var i = 0;
232
+ while (i < src.length) {
224
233
  if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
225
234
  return i;
226
235
  }
236
+ i++;
227
237
  }
228
238
  return -1;
229
239
  }
@@ -242,18 +252,33 @@ function toArray(obj) {
242
252
  * unique array with objects based on a key (like 'id') or just by the array's value
243
253
  * @param {Array} src [{id:1},{id:2},{id:1}]
244
254
  * @param {String} [key]
255
+ * @param {Boolean} [sort=False]
245
256
  * @returns {Array} [{id:1},{id:2}]
246
257
  */
247
- function uniqueArray(src, key) {
258
+ function uniqueArray(src, key, sort) {
248
259
  var results = [];
249
260
  var values = [];
250
- for (var i = 0, len = src.length; i < len; i++) {
261
+ var i = 0;
262
+
263
+ while (i < src.length) {
251
264
  var val = key ? src[i][key] : src[i];
252
265
  if (inArray(values, val) < 0) {
253
266
  results.push(src[i]);
254
267
  }
255
268
  values[i] = val;
269
+ i++;
256
270
  }
271
+
272
+ if (sort) {
273
+ if (!key) {
274
+ results = results.sort();
275
+ } else {
276
+ results = results.sort(function sortUniqueArray(a, b) {
277
+ return a[key] > b[key];
278
+ });
279
+ }
280
+ }
281
+
257
282
  return results;
258
283
  }
259
284
 
@@ -267,13 +292,15 @@ function prefixed(obj, property) {
267
292
  var prefix, prop;
268
293
  var camelProp = property[0].toUpperCase() + property.slice(1);
269
294
 
270
- for (var i = 0, len = VENDOR_PREFIXES.length; i < len; i++) {
295
+ var i = 0;
296
+ while (i < VENDOR_PREFIXES.length) {
271
297
  prefix = VENDOR_PREFIXES[i];
272
298
  prop = (prefix) ? prefix + camelProp : property;
273
299
 
274
300
  if (prop in obj) {
275
301
  return prop;
276
302
  }
303
+ i++;
277
304
  }
278
305
  return undefined;
279
306
  }
@@ -287,6 +314,16 @@ function uniqueId() {
287
314
  return _uniqueId++;
288
315
  }
289
316
 
317
+ /**
318
+ * get the window object of an element
319
+ * @param {HTMLElement} element
320
+ * @returns {DocumentView|Window}
321
+ */
322
+ function getWindowForElement(element) {
323
+ var doc = element.ownerDocument;
324
+ return (doc.defaultView || doc.parentWindow);
325
+ }
326
+
290
327
  var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
291
328
 
292
329
  var SUPPORT_TOUCH = ('ontouchstart' in window);
@@ -329,17 +366,19 @@ function Input(manager, callback) {
329
366
  var self = this;
330
367
  this.manager = manager;
331
368
  this.callback = callback;
369
+ this.element = manager.element;
370
+ this.target = manager.options.inputTarget;
332
371
 
333
372
  // smaller wrapper around the handler, for the scope and the enabled state of the manager,
334
373
  // so when disabled the input events are completely bypassed.
335
374
  this.domHandler = function(ev) {
336
- if (boolOrFn(self.manager.options.enable, [self.manager])) {
375
+ if (boolOrFn(manager.options.enable, [manager])) {
337
376
  self.handler(ev);
338
377
  }
339
378
  };
340
379
 
341
- this.evEl && addEventListeners(this.manager.element, this.evEl, this.domHandler);
342
- this.evWin && addEventListeners(window, this.evWin, this.domHandler);
380
+ this.init();
381
+
343
382
  }
344
383
 
345
384
  Input.prototype = {
@@ -349,23 +388,38 @@ Input.prototype = {
349
388
  */
350
389
  handler: function() { },
351
390
 
391
+ /**
392
+ * bind the events
393
+ */
394
+ init: function() {
395
+ this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
396
+ this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
397
+ this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
398
+ },
399
+
352
400
  /**
353
401
  * unbind the events
354
402
  */
355
403
  destroy: function() {
356
- this.elEvents && removeEventListeners(this.manager.element, this.elEvents, this.domHandler);
357
- this.winEvents && removeEventListeners(window, this.winEvents, this.domHandler);
404
+ this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
405
+ this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
406
+ this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
358
407
  }
359
408
  };
360
409
 
361
410
  /**
362
411
  * create new input type manager
412
+ * called by the Manager constructor
363
413
  * @param {Hammer} manager
364
414
  * @returns {Input}
365
415
  */
366
416
  function createInputInstance(manager) {
367
417
  var Type;
368
- if (SUPPORT_POINTER_EVENTS) {
418
+ var inputClass = manager.options.inputClass;
419
+
420
+ if (inputClass) {
421
+ Type = inputClass;
422
+ } else if (SUPPORT_POINTER_EVENTS) {
369
423
  Type = PointerEventInput;
370
424
  } else if (SUPPORT_ONLY_TOUCH) {
371
425
  Type = TouchInput;
@@ -389,12 +443,13 @@ function inputHandler(manager, eventType, input) {
389
443
  var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
390
444
  var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
391
445
 
392
- input.isFirst = isFirst;
393
- input.isFinal = isFinal;
446
+ input.isFirst = !!isFirst;
447
+ input.isFinal = !!isFinal;
394
448
 
395
449
  if (isFirst) {
396
450
  manager.session = {};
397
451
  }
452
+
398
453
  // source event is the normalized value of the domEvents
399
454
  // like 'touchstart, mouseup, pointerdown'
400
455
  input.eventType = eventType;
@@ -406,6 +461,7 @@ function inputHandler(manager, eventType, input) {
406
461
  manager.emit('hammer.input', input);
407
462
 
408
463
  manager.recognize(input);
464
+ manager.session.prevInput = input;
409
465
  }
410
466
 
411
467
  /**
@@ -433,29 +489,50 @@ function computeInputData(manager, input) {
433
489
  var firstInput = session.firstInput;
434
490
  var firstMultiple = session.firstMultiple;
435
491
  var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
436
- var center = getCenter(pointers);
437
492
 
493
+ var center = input.center = getCenter(pointers);
438
494
  input.timeStamp = now();
439
495
  input.deltaTime = input.timeStamp - firstInput.timeStamp;
440
- input.deltaX = center.x - offsetCenter.x;
441
- input.deltaY = center.y - offsetCenter.y;
442
496
 
443
- input.center = center;
444
497
  input.angle = getAngle(offsetCenter, center);
445
498
  input.distance = getDistance(offsetCenter, center);
499
+
500
+ computeDeltaXY(session, input);
446
501
  input.offsetDirection = getDirection(input.deltaX, input.deltaY);
447
502
 
448
503
  input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
449
504
  input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
450
505
 
506
+ computeIntervalInputData(session, input);
507
+
451
508
  // find the correct target
452
509
  var target = manager.element;
453
510
  if (hasParent(input.srcEvent.target, target)) {
454
511
  target = input.srcEvent.target;
455
512
  }
456
513
  input.target = target;
514
+ }
457
515
 
458
- computeIntervalInputData(session, input);
516
+ function computeDeltaXY(session, input) {
517
+ var center = input.center;
518
+ var offset = session.offsetDelta || {};
519
+ var prevDelta = session.prevDelta || {};
520
+ var prevInput = session.prevInput || {};
521
+
522
+ if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
523
+ prevDelta = session.prevDelta = {
524
+ x: prevInput.deltaX || 0,
525
+ y: prevInput.deltaY || 0
526
+ };
527
+
528
+ offset = session.offsetDelta = {
529
+ x: center.x,
530
+ y: center.y
531
+ };
532
+ }
533
+
534
+ input.deltaX = prevDelta.x + (center.x - offset.x);
535
+ input.deltaY = prevDelta.y + (center.y - offset.y);
459
536
  }
460
537
 
461
538
  /**
@@ -464,18 +541,11 @@ function computeInputData(manager, input) {
464
541
  * @param {Object} input
465
542
  */
466
543
  function computeIntervalInputData(session, input) {
467
- var last = session.lastInterval;
468
- if (!last) {
469
- last = session.lastInterval = simpleCloneInputData(input);
470
- }
544
+ var last = session.lastInterval || input,
545
+ deltaTime = input.timeStamp - last.timeStamp,
546
+ velocity, velocityX, velocityY, direction;
471
547
 
472
- var deltaTime = input.timeStamp - last.timeStamp,
473
- velocity,
474
- velocityX,
475
- velocityY,
476
- direction;
477
-
478
- if (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined) {
548
+ if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
479
549
  var deltaX = last.deltaX - input.deltaX;
480
550
  var deltaY = last.deltaY - input.deltaY;
481
551
 
@@ -484,6 +554,8 @@ function computeIntervalInputData(session, input) {
484
554
  velocityY = v.y;
485
555
  velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
486
556
  direction = getDirection(deltaX, deltaY);
557
+
558
+ session.lastInterval = input;
487
559
  } else {
488
560
  // use latest velocity info if it doesn't overtake a minimum period
489
561
  velocity = last.velocity;
@@ -507,11 +579,13 @@ function simpleCloneInputData(input) {
507
579
  // make a simple copy of the pointers because we will get a reference if we don't
508
580
  // we only need clientXY for the calculations
509
581
  var pointers = [];
510
- for (var i = 0; i < input.pointers.length; i++) {
582
+ var i = 0;
583
+ while (i < input.pointers.length) {
511
584
  pointers[i] = {
512
585
  clientX: round(input.pointers[i].clientX),
513
586
  clientY: round(input.pointers[i].clientY)
514
587
  };
588
+ i++;
515
589
  }
516
590
 
517
591
  return {
@@ -539,10 +613,11 @@ function getCenter(pointers) {
539
613
  };
540
614
  }
541
615
 
542
- var x = 0, y = 0;
543
- for (var i = 0; i < pointersLength; i++) {
616
+ var x = 0, y = 0, i = 0;
617
+ while (i < pointersLength) {
544
618
  x += pointers[i].clientX;
545
619
  y += pointers[i].clientY;
620
+ i++;
546
621
  }
547
622
 
548
623
  return {
@@ -639,12 +714,11 @@ function getScale(start, end) {
639
714
  var MOUSE_INPUT_MAP = {
640
715
  mousedown: INPUT_START,
641
716
  mousemove: INPUT_MOVE,
642
- mouseup: INPUT_END,
643
- mouseout: INPUT_CANCEL
717
+ mouseup: INPUT_END
644
718
  };
645
719
 
646
720
  var MOUSE_ELEMENT_EVENTS = 'mousedown';
647
- var MOUSE_WINDOW_EVENTS = 'mousemove mouseout mouseup';
721
+ var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
648
722
 
649
723
  /**
650
724
  * Mouse events input
@@ -666,7 +740,7 @@ inherit(MouseInput, Input, {
666
740
  * handle mouse events
667
741
  * @param {Object} ev
668
742
  */
669
- handler: function(ev) {
743
+ handler: function MEhandler(ev) {
670
744
  var eventType = MOUSE_INPUT_MAP[ev.type];
671
745
 
672
746
  // on start we want to have the left mouse button down
@@ -683,13 +757,7 @@ inherit(MouseInput, Input, {
683
757
  return;
684
758
  }
685
759
 
686
- // out of the window?
687
- var target = ev.relatedTarget || ev.toElement || ev.target;
688
- if (ev.type == 'mouseout' && target.nodeName != 'HTML') {
689
- eventType = INPUT_MOVE;
690
- }
691
-
692
- if (eventType & (INPUT_END | INPUT_CANCEL)) {
760
+ if (eventType & INPUT_END) {
693
761
  this.pressed = false;
694
762
  }
695
763
 
@@ -699,7 +767,7 @@ inherit(MouseInput, Input, {
699
767
  pointerType: INPUT_TYPE_MOUSE,
700
768
  srcEvent: ev
701
769
  });
702
- },
770
+ }
703
771
  });
704
772
 
705
773
  var POINTER_INPUT_MAP = {
@@ -719,12 +787,12 @@ var IE10_POINTER_TYPE_ENUM = {
719
787
  };
720
788
 
721
789
  var POINTER_ELEMENT_EVENTS = 'pointerdown';
722
- var POINTER_WINDOW_EVENTS = 'pointermove pointerout pointerup pointercancel';
790
+ var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
723
791
 
724
792
  // IE10 has prefixed support, and case-sensitive
725
793
  if (window.MSPointerEvent) {
726
794
  POINTER_ELEMENT_EVENTS = 'MSPointerDown';
727
- POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerOut MSPointerUp MSPointerCancel';
795
+ POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
728
796
  }
729
797
 
730
798
  /**
@@ -746,7 +814,7 @@ inherit(PointerEventInput, Input, {
746
814
  * handle mouse events
747
815
  * @param {Object} ev
748
816
  */
749
- handler: function(ev) {
817
+ handler: function PEhandler(ev) {
750
818
  var store = this.store;
751
819
  var removePointer = false;
752
820
 
@@ -754,22 +822,22 @@ inherit(PointerEventInput, Input, {
754
822
  var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
755
823
  var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
756
824
 
757
- // out of the window?
758
- var target = ev.relatedTarget || ev.toElement || ev.target;
759
- if (eventTypeNormalized == 'pointerout' && target.nodeName != 'HTML') {
760
- eventType = INPUT_MOVE;
761
- }
825
+ var isTouch = (pointerType == INPUT_TYPE_TOUCH);
826
+
827
+ // get index of the event in the store
828
+ var storeIndex = inArray(store, ev.pointerId, 'pointerId');
762
829
 
763
830
  // start and mouse must be down
764
- if (eventType & INPUT_START && (ev.button === 0 || pointerType == INPUT_TYPE_TOUCH)) {
765
- store.push(ev);
831
+ if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
832
+ if (storeIndex < 0) {
833
+ store.push(ev);
834
+ storeIndex = store.length - 1;
835
+ }
766
836
  } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
767
837
  removePointer = true;
768
838
  }
769
839
 
770
- // get index of the event in the store
771
840
  // it not found, so the pointer hasn't been down (so it's probably a hover)
772
- var storeIndex = inArray(store, ev.pointerId, 'pointerId');
773
841
  if (storeIndex < 0) {
774
842
  return;
775
843
  }
@@ -791,35 +859,105 @@ inherit(PointerEventInput, Input, {
791
859
  }
792
860
  });
793
861
 
794
- var TOUCH_INPUT_MAP = {
862
+ var SINGLE_TOUCH_INPUT_MAP = {
795
863
  touchstart: INPUT_START,
796
864
  touchmove: INPUT_MOVE,
797
865
  touchend: INPUT_END,
798
866
  touchcancel: INPUT_CANCEL
799
867
  };
800
868
 
801
- var TOUCH_EVENTS = 'touchstart touchmove touchend touchcancel';
869
+ var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
870
+ var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
802
871
 
803
872
  /**
804
873
  * Touch events input
805
874
  * @constructor
806
875
  * @extends Input
807
876
  */
877
+ function SingleTouchInput() {
878
+ this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
879
+ this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
880
+ this.started = false;
881
+
882
+ Input.apply(this, arguments);
883
+ }
884
+
885
+ inherit(SingleTouchInput, Input, {
886
+ handler: function TEhandler(ev) {
887
+ var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
888
+
889
+ // should we handle the touch events?
890
+ if (type === INPUT_START) {
891
+ this.started = true;
892
+ }
893
+
894
+ if (!this.started) {
895
+ return;
896
+ }
897
+
898
+ var touches = normalizeSingleTouches.call(this, ev, type);
899
+
900
+ // when done, reset the started state
901
+ if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
902
+ this.started = false;
903
+ }
904
+
905
+ this.callback(this.manager, type, {
906
+ pointers: touches[0],
907
+ changedPointers: touches[1],
908
+ pointerType: INPUT_TYPE_TOUCH,
909
+ srcEvent: ev
910
+ });
911
+ }
912
+ });
913
+
914
+ /**
915
+ * @this {TouchInput}
916
+ * @param {Object} ev
917
+ * @param {Number} type flag
918
+ * @returns {undefined|Array} [all, changed]
919
+ */
920
+ function normalizeSingleTouches(ev, type) {
921
+ var all = toArray(ev.touches);
922
+ var changed = toArray(ev.changedTouches);
923
+
924
+ if (type & (INPUT_END | INPUT_CANCEL)) {
925
+ all = uniqueArray(all.concat(changed), 'identifier', true);
926
+ }
927
+
928
+ return [all, changed];
929
+ }
930
+
931
+ var TOUCH_INPUT_MAP = {
932
+ touchstart: INPUT_START,
933
+ touchmove: INPUT_MOVE,
934
+ touchend: INPUT_END,
935
+ touchcancel: INPUT_CANCEL
936
+ };
937
+
938
+ var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
939
+
940
+ /**
941
+ * Multi-user touch events input
942
+ * @constructor
943
+ * @extends Input
944
+ */
808
945
  function TouchInput() {
809
- this.evEl = TOUCH_EVENTS;
946
+ this.evTarget = TOUCH_TARGET_EVENTS;
810
947
  this.targetIds = {};
811
948
 
812
949
  Input.apply(this, arguments);
813
950
  }
814
951
 
815
952
  inherit(TouchInput, Input, {
816
- /**
817
- * handle touch events
818
- * @param {Object} ev
819
- */
820
- handler: function(ev) {
821
- var touches = normalizeTouches(ev, this);
822
- this.callback(this.manager, TOUCH_INPUT_MAP[ev.type], {
953
+ handler: function MTEhandler(ev) {
954
+ var type = TOUCH_INPUT_MAP[ev.type];
955
+ var touches = getTouches.call(this, ev, type);
956
+ if (!touches) {
957
+ return;
958
+ }
959
+
960
+ this.callback(this.manager, type, {
823
961
  pointers: touches[0],
824
962
  changedPointers: touches[1],
825
963
  pointerType: INPUT_TYPE_TOUCH,
@@ -829,44 +967,62 @@ inherit(TouchInput, Input, {
829
967
  });
830
968
 
831
969
  /**
832
- * make sure all browsers return the same touches
970
+ * @this {TouchInput}
833
971
  * @param {Object} ev
834
- * @param {TouchInput} touchInput
835
- * @returns {Array} [all, changed]
972
+ * @param {Number} type flag
973
+ * @returns {undefined|Array} [all, changed]
836
974
  */
837
- function normalizeTouches(ev, touchInput) {
838
- var i, len;
975
+ function getTouches(ev, type) {
976
+ var allTouches = toArray(ev.touches);
977
+ var targetIds = this.targetIds;
978
+
979
+ // when there is only one touch, the process can be simplified
980
+ if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
981
+ targetIds[allTouches[0].identifier] = true;
982
+ return [allTouches, allTouches];
983
+ }
839
984
 
840
- var targetIds = touchInput.targetIds;
841
- var targetTouches = toArray(ev.targetTouches);
842
- var changedTouches = toArray(ev.changedTouches);
843
- var changedTargetTouches = [];
985
+ var i,
986
+ targetTouches,
987
+ changedTouches = toArray(ev.changedTouches),
988
+ changedTargetTouches = [],
989
+ target = this.target;
990
+
991
+ // get target touches from touches
992
+ targetTouches = allTouches.filter(function(touch) {
993
+ return hasParent(touch.target, target);
994
+ });
844
995
 
845
996
  // collect touches
846
- if (ev.type == 'touchstart') {
847
- for (i = 0, len = targetTouches.length; i < len; i++) {
997
+ if (type === INPUT_START) {
998
+ i = 0;
999
+ while (i < targetTouches.length) {
848
1000
  targetIds[targetTouches[i].identifier] = true;
1001
+ i++;
849
1002
  }
850
1003
  }
851
1004
 
852
1005
  // filter changed touches to only contain touches that exist in the collected target ids
853
- for (i = 0, len = changedTouches.length; i < len; i++) {
1006
+ i = 0;
1007
+ while (i < changedTouches.length) {
854
1008
  if (targetIds[changedTouches[i].identifier]) {
855
1009
  changedTargetTouches.push(changedTouches[i]);
856
1010
  }
857
1011
 
858
1012
  // cleanup removed touches
859
- if (ev.type == 'touchend'|| ev.type == 'touchcancel') {
1013
+ if (type & (INPUT_END | INPUT_CANCEL)) {
860
1014
  delete targetIds[changedTouches[i].identifier];
861
1015
  }
1016
+ i++;
1017
+ }
1018
+
1019
+ if (!changedTargetTouches.length) {
1020
+ return;
862
1021
  }
863
1022
 
864
1023
  return [
865
1024
  // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
866
- // also removed the duplicates
867
- uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier'),
868
-
869
- // only the changed :-)
1025
+ uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
870
1026
  changedTargetTouches
871
1027
  ];
872
1028
  }
@@ -895,7 +1051,7 @@ inherit(TouchMouseInput, Input, {
895
1051
  * @param {String} inputEvent
896
1052
  * @param {Object} inputData
897
1053
  */
898
- handler: function(manager, inputEvent, inputData) {
1054
+ handler: function TMEhandler(manager, inputEvent, inputData) {
899
1055
  var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
900
1056
  isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
901
1057
 
@@ -918,7 +1074,7 @@ inherit(TouchMouseInput, Input, {
918
1074
  /**
919
1075
  * remove the event listeners
920
1076
  */
921
- destroy: function() {
1077
+ destroy: function destroy() {
922
1078
  this.touch.destroy();
923
1079
  this.mouse.destroy();
924
1080
  }
@@ -930,7 +1086,7 @@ var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
930
1086
  // magical touchAction value
931
1087
  var TOUCH_ACTION_COMPUTE = 'compute';
932
1088
  var TOUCH_ACTION_AUTO = 'auto';
933
- var TOUCH_ACTION_MANIPULATION = 'manipulation';
1089
+ var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
934
1090
  var TOUCH_ACTION_NONE = 'none';
935
1091
  var TOUCH_ACTION_PAN_X = 'pan-x';
936
1092
  var TOUCH_ACTION_PAN_Y = 'pan-y';
@@ -1009,7 +1165,7 @@ TouchAction.prototype = {
1009
1165
  var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
1010
1166
  var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
1011
1167
 
1012
- if (hasNone || (hasPanY && hasPanX) ||
1168
+ if (hasNone ||
1013
1169
  (hasPanY && direction & DIRECTION_HORIZONTAL) ||
1014
1170
  (hasPanX && direction & DIRECTION_VERTICAL)) {
1015
1171
  return this.preventSrc(srcEvent);
@@ -1228,8 +1384,24 @@ Recognizer.prototype = {
1228
1384
  * @param {Object} input
1229
1385
  */
1230
1386
  emit: function(input) {
1231
- this.manager.emit(this.options.event, input); // simple 'eventName' events
1232
- this.manager.emit(this.options.event + stateStr(this.state), input); // like 'panmove' and 'panstart'
1387
+ var self = this;
1388
+ var state = this.state;
1389
+
1390
+ function emit(withState) {
1391
+ self.manager.emit(self.options.event + (withState ? stateStr(state) : ''), input);
1392
+ }
1393
+
1394
+ // 'panstart' and 'panmove'
1395
+ if (state < STATE_ENDED) {
1396
+ emit(true);
1397
+ }
1398
+
1399
+ emit(); // simple 'eventName' events
1400
+
1401
+ // panend and pancancel
1402
+ if (state >= STATE_ENDED) {
1403
+ emit(true);
1404
+ }
1233
1405
  },
1234
1406
 
1235
1407
  /**
@@ -1251,10 +1423,12 @@ Recognizer.prototype = {
1251
1423
  * @returns {boolean}
1252
1424
  */
1253
1425
  canEmit: function() {
1254
- for (var i = 0; i < this.requireFail.length; i++) {
1426
+ var i = 0;
1427
+ while (i < this.requireFail.length) {
1255
1428
  if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
1256
1429
  return false;
1257
1430
  }
1431
+ i++;
1258
1432
  }
1259
1433
  return true;
1260
1434
  },
@@ -1451,11 +1625,6 @@ inherit(PanRecognizer, AttrRecognizer, {
1451
1625
 
1452
1626
  getTouchAction: function() {
1453
1627
  var direction = this.options.direction;
1454
-
1455
- if (direction === DIRECTION_ALL) {
1456
- return [TOUCH_ACTION_NONE];
1457
- }
1458
-
1459
1628
  var actions = [];
1460
1629
  if (direction & DIRECTION_HORIZONTAL) {
1461
1630
  actions.push(TOUCH_ACTION_PAN_Y);
@@ -1499,12 +1668,12 @@ inherit(PanRecognizer, AttrRecognizer, {
1499
1668
  this.pX = input.deltaX;
1500
1669
  this.pY = input.deltaY;
1501
1670
 
1502
- this._super.emit.call(this, input);
1503
-
1504
1671
  var direction = directionStr(input.direction);
1505
1672
  if (direction) {
1506
1673
  this.manager.emit(this.options.event + direction, input);
1507
1674
  }
1675
+
1676
+ this._super.emit.call(this, input);
1508
1677
  }
1509
1678
  });
1510
1679
 
@@ -1578,7 +1747,6 @@ inherit(PressRecognizer, Recognizer, {
1578
1747
 
1579
1748
  process: function(input) {
1580
1749
  var options = this.options;
1581
-
1582
1750
  var validPointers = input.pointers.length === options.pointers;
1583
1751
  var validMovement = input.distance < options.threshold;
1584
1752
  var validTime = input.deltaTime > options.time;
@@ -1591,7 +1759,7 @@ inherit(PressRecognizer, Recognizer, {
1591
1759
  this.reset();
1592
1760
  } else if (input.eventType & INPUT_START) {
1593
1761
  this.reset();
1594
- this._timer = setTimeoutScope(function() {
1762
+ this._timer = setTimeoutContext(function() {
1595
1763
  this.state = STATE_RECOGNIZED;
1596
1764
  this.tryEmit();
1597
1765
  }, options.time, this);
@@ -1691,16 +1859,17 @@ inherit(SwipeRecognizer, AttrRecognizer, {
1691
1859
 
1692
1860
  return this._super.attrTest.call(this, input) &&
1693
1861
  direction & input.direction &&
1862
+ input.distance > this.options.threshold &&
1694
1863
  abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
1695
1864
  },
1696
1865
 
1697
1866
  emit: function(input) {
1698
- this.manager.emit(this.options.event, input);
1699
-
1700
1867
  var direction = directionStr(input.direction);
1701
1868
  if (direction) {
1702
1869
  this.manager.emit(this.options.event + direction, input);
1703
1870
  }
1871
+
1872
+ this.manager.emit(this.options.event, input);
1704
1873
  }
1705
1874
  });
1706
1875
 
@@ -1756,14 +1925,14 @@ inherit(TapRecognizer, Recognizer, {
1756
1925
  this.reset();
1757
1926
 
1758
1927
  if ((input.eventType & INPUT_START) && (this.count === 0)) {
1759
- return this._failTimeout();
1928
+ return this.failTimeout();
1760
1929
  }
1761
1930
 
1762
1931
  // we only allow little movement
1763
1932
  // and we've reached an end event, so a tap is possible
1764
1933
  if (validMovement && validTouchTime && validPointers) {
1765
1934
  if (input.eventType != INPUT_END) {
1766
- return this._failTimeout();
1935
+ return this.failTimeout();
1767
1936
  }
1768
1937
 
1769
1938
  var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
@@ -1789,7 +1958,7 @@ inherit(TapRecognizer, Recognizer, {
1789
1958
  if (!this.hasRequireFailures()) {
1790
1959
  return STATE_RECOGNIZED;
1791
1960
  } else {
1792
- this._timer = setTimeoutScope(function() {
1961
+ this._timer = setTimeoutContext(function() {
1793
1962
  this.state = STATE_RECOGNIZED;
1794
1963
  this.tryEmit();
1795
1964
  }, options.interval, this);
@@ -1800,8 +1969,8 @@ inherit(TapRecognizer, Recognizer, {
1800
1969
  return STATE_FAILED;
1801
1970
  },
1802
1971
 
1803
- _failTimeout: function() {
1804
- this._timer = setTimeoutScope(function() {
1972
+ failTimeout: function() {
1973
+ this._timer = setTimeoutContext(function() {
1805
1974
  this.state = STATE_FAILED;
1806
1975
  }, this.options.interval, this);
1807
1976
  return STATE_FAILED;
@@ -1834,7 +2003,7 @@ function Hammer(element, options) {
1834
2003
  /**
1835
2004
  * @const {string}
1836
2005
  */
1837
- Hammer.VERSION = '2.0.1';
2006
+ Hammer.VERSION = '2.0.4';
1838
2007
 
1839
2008
  /**
1840
2009
  * default settings
@@ -1863,6 +2032,22 @@ Hammer.defaults = {
1863
2032
  */
1864
2033
  enable: true,
1865
2034
 
2035
+ /**
2036
+ * EXPERIMENTAL FEATURE -- can be removed/changed
2037
+ * Change the parent input target element.
2038
+ * If Null, then it is being set the to main element.
2039
+ * @type {Null|EventTarget}
2040
+ * @default null
2041
+ */
2042
+ inputTarget: null,
2043
+
2044
+ /**
2045
+ * force an input class
2046
+ * @type {Null|Function}
2047
+ * @default null
2048
+ */
2049
+ inputClass: null,
2050
+
1866
2051
  /**
1867
2052
  * Default recognizer setup when calling `Hammer()`
1868
2053
  * When creating a new Manager these will be skipped.
@@ -1886,8 +2071,7 @@ Hammer.defaults = {
1886
2071
  */
1887
2072
  cssProps: {
1888
2073
  /**
1889
- * Disables text selection to improve the dragging gesture. When the value is `none` it also sets
1890
- * `onselectstart=false` for IE9 on the element. Mainly for desktop browsers.
2074
+ * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
1891
2075
  * @type {String}
1892
2076
  * @default 'none'
1893
2077
  */
@@ -1946,6 +2130,7 @@ function Manager(element, options) {
1946
2130
  options = options || {};
1947
2131
 
1948
2132
  this.options = merge(options, Hammer.defaults);
2133
+ this.options.inputTarget = this.options.inputTarget || element;
1949
2134
 
1950
2135
  this.handlers = {};
1951
2136
  this.session = {};
@@ -1960,7 +2145,7 @@ function Manager(element, options) {
1960
2145
  each(options.recognizers, function(item) {
1961
2146
  var recognizer = this.add(new (item[0])(item[1]));
1962
2147
  item[2] && recognizer.recognizeWith(item[2]);
1963
- item[3] && recognizer.requireFailure(item[2]);
2148
+ item[3] && recognizer.requireFailure(item[3]);
1964
2149
  }, this);
1965
2150
  }
1966
2151
 
@@ -1972,6 +2157,17 @@ Manager.prototype = {
1972
2157
  */
1973
2158
  set: function(options) {
1974
2159
  extend(this.options, options);
2160
+
2161
+ // Options that need a little more setup
2162
+ if (options.touchAction) {
2163
+ this.touchAction.update();
2164
+ }
2165
+ if (options.inputTarget) {
2166
+ // Clean up existing event listeners and reinitialize
2167
+ this.input.destroy();
2168
+ this.input.target = options.inputTarget;
2169
+ this.input.init();
2170
+ }
1975
2171
  return this;
1976
2172
  },
1977
2173
 
@@ -1992,7 +2188,8 @@ Manager.prototype = {
1992
2188
  * @param {Object} inputData
1993
2189
  */
1994
2190
  recognize: function(inputData) {
1995
- if (this.session.stopped) {
2191
+ var session = this.session;
2192
+ if (session.stopped) {
1996
2193
  return;
1997
2194
  }
1998
2195
 
@@ -2000,7 +2197,7 @@ Manager.prototype = {
2000
2197
  this.touchAction.preventDefaults(inputData);
2001
2198
 
2002
2199
  var recognizer;
2003
- var session = this.session;
2200
+ var recognizers = this.recognizers;
2004
2201
 
2005
2202
  // this holds the recognizer that is being recognized.
2006
2203
  // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
@@ -2013,8 +2210,9 @@ Manager.prototype = {
2013
2210
  curRecognizer = session.curRecognizer = null;
2014
2211
  }
2015
2212
 
2016
- for (var i = 0, len = this.recognizers.length; i < len; i++) {
2017
- recognizer = this.recognizers[i];
2213
+ var i = 0;
2214
+ while (i < recognizers.length) {
2215
+ recognizer = recognizers[i];
2018
2216
 
2019
2217
  // find out if we are allowed try to recognize the input for this one.
2020
2218
  // 1. allow if the session is NOT forced stopped (see the .stop() method)
@@ -2022,7 +2220,7 @@ Manager.prototype = {
2022
2220
  // that is being recognized.
2023
2221
  // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
2024
2222
  // this can be setup with the `recognizeWith()` method on the recognizer.
2025
- if (this.session.stopped !== FORCED_STOP && ( // 1
2223
+ if (session.stopped !== FORCED_STOP && ( // 1
2026
2224
  !curRecognizer || recognizer == curRecognizer || // 2
2027
2225
  recognizer.canRecognizeWith(curRecognizer))) { // 3
2028
2226
  recognizer.recognize(inputData);
@@ -2035,6 +2233,7 @@ Manager.prototype = {
2035
2233
  if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
2036
2234
  curRecognizer = session.curRecognizer = recognizer;
2037
2235
  }
2236
+ i++;
2038
2237
  }
2039
2238
  },
2040
2239
 
@@ -2144,7 +2343,7 @@ Manager.prototype = {
2144
2343
  }
2145
2344
 
2146
2345
  // no handlers, so skip it all
2147
- var handlers = this.handlers[event];
2346
+ var handlers = this.handlers[event] && this.handlers[event].slice();
2148
2347
  if (!handlers || !handlers.length) {
2149
2348
  return;
2150
2349
  }
@@ -2154,8 +2353,10 @@ Manager.prototype = {
2154
2353
  data.srcEvent.preventDefault();
2155
2354
  };
2156
2355
 
2157
- for (var i = 0, len = handlers.length; i < len; i++) {
2356
+ var i = 0;
2357
+ while (i < handlers.length) {
2158
2358
  handlers[i](data);
2359
+ i++;
2159
2360
  }
2160
2361
  },
2161
2362
 
@@ -2180,15 +2381,9 @@ Manager.prototype = {
2180
2381
  */
2181
2382
  function toggleCssProps(manager, add) {
2182
2383
  var element = manager.element;
2183
- var cssProps = manager.options.cssProps;
2184
-
2185
- each(cssProps, function(value, name) {
2384
+ each(manager.options.cssProps, function(value, name) {
2186
2385
  element.style[prefixed(element.style, name)] = add ? value : '';
2187
2386
  });
2188
-
2189
- var falseFn = add && function() { return false; };
2190
- if (cssProps.userSelect == 'none') { element.onselectstart = falseFn; }
2191
- if (cssProps.userDrag == 'none') { element.ondragstart = falseFn; }
2192
2387
  }
2193
2388
 
2194
2389
  /**
@@ -2230,6 +2425,12 @@ extend(Hammer, {
2230
2425
  Input: Input,
2231
2426
  TouchAction: TouchAction,
2232
2427
 
2428
+ TouchInput: TouchInput,
2429
+ MouseInput: MouseInput,
2430
+ PointerEventInput: PointerEventInput,
2431
+ TouchMouseInput: TouchMouseInput,
2432
+ SingleTouchInput: SingleTouchInput,
2433
+
2233
2434
  Recognizer: Recognizer,
2234
2435
  AttrRecognizer: AttrRecognizer,
2235
2436
  Tap: TapRecognizer,
@@ -2253,10 +2454,10 @@ if (typeof define == TYPE_FUNCTION && define.amd) {
2253
2454
  define(function() {
2254
2455
  return Hammer;
2255
2456
  });
2256
- } else if (typeof module != TYPE_UNDEFINED && module.exports) {
2457
+ } else if (typeof module != 'undefined' && module.exports) {
2257
2458
  module.exports = Hammer;
2258
2459
  } else {
2259
- window.Hammer = Hammer;
2460
+ window[exportName] = Hammer;
2260
2461
  }
2261
2462
 
2262
- })(window);
2463
+ })(window, document, 'Hammer');
@@ -1,9 +1,7 @@
1
- /*! Hammer.JS - v2.0.1 - 2014-07-15
1
+ /*! Hammer.JS - v2.0.4 - 2014-09-28
2
2
  * http://hammerjs.github.io/
3
3
  *
4
- * Copyright (c) 2014 Jorik Tangelder <j.tangelder@gmail.com>;
4
+ * Copyright (c) 2014 Jorik Tangelder;
5
5
  * Licensed under the MIT license */
6
-
7
-
8
- !function(a,b){"use strict";function c(a,b,c){return setTimeout(i(a,c),b)}function d(a,b,c){return Array.isArray(a)?(e(a,c[b],c),!0):!1}function e(a,c,d){var e,f;if(a)if(a.forEach)a.forEach(c,d);else if(a.length!==b)for(e=0,f=a.length;f>e;e++)c.call(d,a[e],e,a);else for(e in a)a.hasOwnProperty(e)&&c.call(d,a[e],e,a)}function f(a,c,d){for(var e=Object.keys(c),f=0,g=e.length;g>f;f++)(!d||d&&a[e[f]]===b)&&(a[e[f]]=c[e[f]]);return a}function g(a,b){return f(a,b,!0)}function h(a,b,c){var d,e=b.prototype;d=a.prototype=Object.create(e),d.constructor=a,d._super=e,c&&f(d,c)}function i(a,b){return function(){return a.apply(b,arguments)}}function j(a,c){return typeof a==eb?a.apply(c?c[0]||b:b,c):a}function k(a,c){return a===b?c:a}function l(a,b,c){e(p(b),function(b){a.addEventListener(b,c,!1)})}function m(a,b,c){e(p(b),function(b){a.removeEventListener(b,c,!1)})}function n(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function o(a,b){return a.indexOf(b)>-1}function p(a){return a.trim().split(/\s+/g)}function q(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0,e=a.length;e>d;d++)if(c&&a[d][c]==b||!c&&a[d]===b)return d;return-1}function r(a){return Array.prototype.slice.call(a,0)}function s(a,b){for(var c=[],d=[],e=0,f=a.length;f>e;e++){var g=b?a[e][b]:a[e];q(d,g)<0&&c.push(a[e]),d[e]=g}return c}function t(a,c){for(var d,e,f=c[0].toUpperCase()+c.slice(1),g=0,h=cb.length;h>g;g++)if(d=cb[g],e=d?d+f:c,e in a)return e;return b}function u(){return jb++}function v(b,c){var d=this;this.manager=b,this.callback=c,this.domHandler=function(a){j(d.manager.options.enable,[d.manager])&&d.handler(a)},this.evEl&&l(this.manager.element,this.evEl,this.domHandler),this.evWin&&l(a,this.evWin,this.domHandler)}function w(a){var b;return new(b=mb?J:nb?K:lb?M:I)(a,x)}function x(a,b,c){var d=c.pointers.length,e=c.changedPointers.length,f=b&tb&&d-e===0,g=b&(vb|wb)&&d-e===0;c.isFirst=f,c.isFinal=g,f&&(a.session={}),c.eventType=b,y(a,c),a.emit("hammer.input",c),a.recognize(c)}function y(a,b){var c=a.session,d=b.pointers,e=d.length;c.firstInput||(c.firstInput=A(b)),e>1&&!c.firstMultiple?c.firstMultiple=A(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=B(d);b.timeStamp=ib(),b.deltaTime=b.timeStamp-f.timeStamp,b.deltaX=i.x-h.x,b.deltaY=i.y-h.y,b.center=i,b.angle=F(h,i),b.distance=E(h,i),b.offsetDirection=D(b.deltaX,b.deltaY),b.scale=g?H(g.pointers,d):1,b.rotation=g?G(g.pointers,d):0;var j=a.element;n(b.srcEvent.target,j)&&(j=b.srcEvent.target),b.target=j,z(c,b)}function z(a,c){var d=a.lastInterval;d||(d=a.lastInterval=A(c));var e,f,g,h,i=c.timeStamp-d.timeStamp;if(i>sb||d.velocity===b){var j=d.deltaX-c.deltaX,k=d.deltaY-c.deltaY,l=C(i,j,k);f=l.x,g=l.y,e=hb(l.x)>hb(l.y)?l.x:l.y,h=D(j,k)}else e=d.velocity,f=d.velocityX,g=d.velocityY,h=d.direction;c.velocity=e,c.velocityX=f,c.velocityY=g,c.direction=h}function A(a){for(var b=[],c=0;c<a.pointers.length;c++)b[c]={clientX:gb(a.pointers[c].clientX),clientY:gb(a.pointers[c].clientY)};return{timeStamp:ib(),pointers:b,center:B(b),deltaX:a.deltaX,deltaY:a.deltaY}}function B(a){var b=a.length;if(1===b)return{x:gb(a[0].clientX),y:gb(a[0].clientY)};for(var c=0,d=0,e=0;b>e;e++)c+=a[e].clientX,d+=a[e].clientY;return{x:gb(c/b),y:gb(d/b)}}function C(a,b,c){return{x:b/a||0,y:c/a||0}}function D(a,b){return a===b?xb:hb(a)>=hb(b)?a>0?yb:zb:b>0?Ab:Bb}function E(a,b,c){c||(c=Fb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function F(a,b,c){c||(c=Fb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function G(a,b){return F(b[1],b[0],Gb)-F(a[1],a[0],Gb)}function H(a,b){return E(b[0],b[1],Gb)/E(a[0],a[1],Gb)}function I(){this.evEl=Ib,this.evWin=Jb,this.allow=!0,this.pressed=!1,v.apply(this,arguments)}function J(){this.evEl=Mb,this.evWin=Nb,v.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function K(){this.evEl=Pb,this.targetIds={},v.apply(this,arguments)}function L(a,b){var c,d,e=b.targetIds,f=r(a.targetTouches),g=r(a.changedTouches),h=[];if("touchstart"==a.type)for(c=0,d=f.length;d>c;c++)e[f[c].identifier]=!0;for(c=0,d=g.length;d>c;c++)e[g[c].identifier]&&h.push(g[c]),("touchend"==a.type||"touchcancel"==a.type)&&delete e[g[c].identifier];return[s(f.concat(h),"identifier"),h]}function M(){v.apply(this,arguments);var a=i(this.handler,this);this.touch=new K(this.manager,a),this.mouse=new I(this.manager,a)}function N(a,b){this.manager=a,this.set(b)}function O(a){if(o(a,Vb))return Vb;var b=o(a,Wb),c=o(a,Xb);return b&&c?Wb+" "+Xb:b||c?b?Wb:Xb:o(a,Ub)?Ub:Tb}function P(a){this.id=u(),this.manager=null,this.options=g(a||{},this.defaults),this.options.enable=k(this.options.enable,!0),this.state=Yb,this.simultaneous={},this.requireFail=[]}function Q(a){return a&bc?"cancel":a&_b?"end":a&$b?"move":a&Zb?"start":""}function R(a){return a==Bb?"down":a==Ab?"up":a==yb?"left":a==zb?"right":""}function S(a,b){var c=b.manager;return c?c.get(a):a}function T(){P.apply(this,arguments)}function U(){T.apply(this,arguments),this.pX=null,this.pY=null}function V(){T.apply(this,arguments)}function W(){P.apply(this,arguments),this._timer=null,this._input=null}function X(){T.apply(this,arguments)}function Y(){T.apply(this,arguments)}function Z(){P.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function $(a,b){return b=b||{},b.recognizers=k(b.recognizers,$.defaults.preset),new _(a,b)}function _(a,b){b=b||{},this.options=g(b,$.defaults),this.handlers={},this.session={},this.recognizers=[],this.element=a,this.input=w(this),this.touchAction=new N(this,this.options.touchAction),ab(this,!0),e(b.recognizers,function(a){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[2])},this)}function ab(a,b){var c=a.element,d=a.options.cssProps;e(d,function(a,d){c.style[t(c.style,d)]=b?a:""});var f=b&&function(){return!1};"none"==d.userSelect&&(c.onselectstart=f),"none"==d.userDrag&&(c.ondragstart=f)}function bb(a,b){var c=document.createEvent("Event");c.initEvent(a,!0,!0),c.gesture=b,b.target.dispatchEvent(c)}var cb=["","webkit","moz","MS","ms","o"],db=document.createElement("div"),eb="function",fb="undefined",gb=Math.round,hb=Math.abs,ib=Date.now,jb=1,kb=/mobile|tablet|ip(ad|hone|od)|android/i,lb="ontouchstart"in a,mb=t(a,"PointerEvent")!==b,nb=lb&&kb.test(navigator.userAgent),ob="touch",pb="pen",qb="mouse",rb="kinect",sb=25,tb=1,ub=2,vb=4,wb=8,xb=1,yb=2,zb=4,Ab=8,Bb=16,Cb=yb|zb,Db=Ab|Bb,Eb=Cb|Db,Fb=["x","y"],Gb=["clientX","clientY"];v.prototype={handler:function(){},destroy:function(){this.elEvents&&m(this.manager.element,this.elEvents,this.domHandler),this.winEvents&&m(a,this.winEvents,this.domHandler)}};var Hb={mousedown:tb,mousemove:ub,mouseup:vb,mouseout:wb},Ib="mousedown",Jb="mousemove mouseout mouseup";h(I,v,{handler:function(a){var b=Hb[a.type];if(b&tb&&0===a.button&&(this.pressed=!0),b&ub&&1!==a.which&&(b=vb),this.pressed&&this.allow){var c=a.relatedTarget||a.toElement||a.target;"mouseout"==a.type&&"HTML"!=c.nodeName&&(b=ub),b&(vb|wb)&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:qb,srcEvent:a})}}});var Kb={pointerdown:tb,pointermove:ub,pointerup:vb,pointercancel:wb,pointerout:wb},Lb={2:ob,3:pb,4:qb,5:rb},Mb="pointerdown",Nb="pointermove pointerout pointerup pointercancel";a.MSPointerEvent&&(Mb="MSPointerDown",Nb="MSPointerMove MSPointerOut MSPointerUp MSPointerCancel"),h(J,v,{handler:function(a){var b=this.store,c=!1,d=a.type.toLowerCase().replace("ms",""),e=Kb[d],f=Lb[a.pointerType]||a.pointerType,g=a.relatedTarget||a.toElement||a.target;"pointerout"==d&&"HTML"!=g.nodeName&&(e=ub),e&tb&&(0===a.button||f==ob)?b.push(a):e&(vb|wb)&&(c=!0);var h=q(b,a.pointerId,"pointerId");0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Ob={touchstart:tb,touchmove:ub,touchend:vb,touchcancel:wb},Pb="touchstart touchmove touchend touchcancel";h(K,v,{handler:function(a){var b=L(a,this);this.callback(this.manager,Ob[a.type],{pointers:b[0],changedPointers:b[1],pointerType:ob,srcEvent:a})}}),h(M,v,{handler:function(a,b,c){var d=c.pointerType==ob,e=c.pointerType==qb;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(vb|wb)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Qb=t(db.style,"touchAction"),Rb=Qb!==b,Sb="compute",Tb="auto",Ub="manipulation",Vb="none",Wb="pan-x",Xb="pan-y";N.prototype={set:function(a){a==Sb&&(a=this.compute()),Rb&&(this.manager.element.style[Qb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return e(this.manager.recognizers,function(b){j(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),O(a.join(" "))},preventDefaults:function(a){if(!Rb){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=o(d,Vb),f=o(d,Xb),g=o(d,Wb);return e||f&&g||f&&c&Cb||g&&c&Db?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var Yb=1,Zb=2,$b=4,_b=8,ac=_b,bc=16,cc=32;P.prototype={defaults:{},set:function(a){return f(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(d(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=S(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return d(a,"dropRecognizeWith",this)?this:(a=S(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(d(a,"requireFailure",this))return this;var b=this.requireFail;return a=S(a,this),-1===q(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(d(a,"dropRequireFailure",this))return this;a=S(a,this);var b=q(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){this.manager.emit(this.options.event,a),this.manager.emit(this.options.event+Q(this.state),a)},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=cc)},canEmit:function(){for(var a=0;a<this.requireFail.length;a++)if(!(this.requireFail[a].state&(cc|Yb)))return!1;return!0},recognize:function(a){var b=f({},a);return j(this.options.enable,[this,b])?(this.state&(ac|bc|cc)&&(this.state=Yb),this.state=this.process(b),void(this.state&(Zb|$b|_b|bc)&&this.tryEmit(b))):(this.reset(),void(this.state=cc))},process:function(){},getTouchAction:function(){},reset:function(){}},h(T,P,{defaults:{pointers:1},attrTest:function(a){var b=this.options.pointers;return 0===b||a.pointers.length===b},process:function(a){var b=this.state,c=a.eventType,d=b&(Zb|$b),e=this.attrTest(a);return d&&(c&wb||!e)?b|bc:d||e?c&vb?b|_b:b&Zb?b|$b:Zb:cc}}),h(U,T,{defaults:{event:"pan",threshold:10,pointers:1,direction:Eb},getTouchAction:function(){var a=this.options.direction;if(a===Eb)return[Vb];var b=[];return a&Cb&&b.push(Xb),a&Db&&b.push(Wb),b},directionTest:function(a){var b=this.options,c=!0,d=a.distance,e=a.direction,f=a.deltaX,g=a.deltaY;return e&b.direction||(b.direction&Cb?(e=0===f?xb:0>f?yb:zb,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?xb:0>g?Ab:Bb,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return T.prototype.attrTest.call(this,a)&&(this.state&Zb||!(this.state&Zb)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY,this._super.emit.call(this,a);var b=R(a.direction);b&&this.manager.emit(this.options.event+b,a)}}),h(V,T,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Vb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&Zb)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),h(W,P,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[Tb]},process:function(a){var b=this.options,d=a.pointers.length===b.pointers,e=a.distance<b.threshold,f=a.deltaTime>b.time;if(this._input=a,!e||!d||a.eventType&(vb|wb)&&!f)this.reset();else if(a.eventType&tb)this.reset(),this._timer=c(function(){this.state=ac,this.tryEmit()},b.time,this);else if(a.eventType&vb)return ac;return cc},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===ac&&(a&&a.eventType&vb?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=ib(),this.manager.emit(this.options.event,this._input)))}}),h(X,T,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Vb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&Zb)}}),h(Y,T,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Cb|Db,pointers:1},getTouchAction:function(){return U.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Cb|Db)?b=a.velocity:c&Cb?b=a.velocityX:c&Db&&(b=a.velocityY),this._super.attrTest.call(this,a)&&c&a.direction&&hb(b)>this.options.velocity&&a.eventType&vb},emit:function(a){this.manager.emit(this.options.event,a);var b=R(a.direction);b&&this.manager.emit(this.options.event+b,a)}}),h(Z,P,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[Ub]},process:function(a){var b=this.options,d=a.pointers.length===b.pointers,e=a.distance<b.threshold,f=a.deltaTime<b.time;if(this.reset(),a.eventType&tb&&0===this.count)return this._failTimeout();if(e&&f&&d){if(a.eventType!=vb)return this._failTimeout();var g=this.pTime?a.timeStamp-this.pTime<b.interval:!0,h=!this.pCenter||E(this.pCenter,a.center)<b.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,h&&g?this.count+=1:this.count=1,this._input=a;var i=this.count%b.taps;if(0===i)return this.hasRequireFailures()?(this._timer=c(function(){this.state=ac,this.tryEmit()},b.interval,this),Zb):ac}return cc},_failTimeout:function(){return this._timer=c(function(){this.state=cc},this.options.interval,this),cc},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==ac&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),$.VERSION="2.0.1",$.defaults={domEvents:!1,touchAction:Sb,enable:!0,preset:[[X,{enable:!1}],[V,{enable:!1},["rotate"]],[Y,{direction:Cb}],[U,{direction:Cb},["swipe"]],[Z],[Z,{event:"doubletap",taps:2},["tap"]],[W]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var dc=1,ec=2;_.prototype={set:function(a){return f(this.options,a),this},stop:function(a){this.session.stopped=a?ec:dc},recognize:function(a){if(!this.session.stopped){this.touchAction.preventDefaults(a);var b,c=this.session,d=c.curRecognizer;(!d||d&&d.state&ac)&&(d=c.curRecognizer=null);for(var e=0,f=this.recognizers.length;f>e;e++)b=this.recognizers[e],this.session.stopped===ec||d&&b!=d&&!b.canRecognizeWith(d)?b.reset():b.recognize(a),!d&&b.state&(Zb|$b|_b)&&(d=c.curRecognizer=b)}},get:function(a){if(a instanceof P)return a;for(var b=this.recognizers,c=0;c<b.length;c++)if(b[c].options.event==a)return b[c];return null},add:function(a){if(d(a,"add",this))return this;var b=this.get(a.options.event);return b&&this.remove(b),this.recognizers.push(a),a.manager=this,this.touchAction.update(),a},remove:function(a){if(d(a,"remove",this))return this;var b=this.recognizers;return a=this.get(a),b.splice(q(b,a),1),this.touchAction.update(),this},on:function(a,b){var c=this.handlers;return e(p(a),function(a){c[a]=c[a]||[],c[a].push(b)}),this},off:function(a,b){var c=this.handlers;return e(p(a),function(a){b?c[a].splice(q(c[a],b),1):delete c[a]}),this},emit:function(a,b){this.options.domEvents&&bb(a,b);var c=this.handlers[a];if(c&&c.length){b.type=a,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var d=0,e=c.length;e>d;d++)c[d](b)}},destroy:function(){this.element&&ab(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},f($,{INPUT_START:tb,INPUT_MOVE:ub,INPUT_END:vb,INPUT_CANCEL:wb,STATE_POSSIBLE:Yb,STATE_BEGAN:Zb,STATE_CHANGED:$b,STATE_ENDED:_b,STATE_RECOGNIZED:ac,STATE_CANCELLED:bc,STATE_FAILED:cc,DIRECTION_NONE:xb,DIRECTION_LEFT:yb,DIRECTION_RIGHT:zb,DIRECTION_UP:Ab,DIRECTION_DOWN:Bb,DIRECTION_HORIZONTAL:Cb,DIRECTION_VERTICAL:Db,DIRECTION_ALL:Eb,Manager:_,Input:v,TouchAction:N,Recognizer:P,AttrRecognizer:T,Tap:Z,Pan:U,Swipe:Y,Pinch:V,Rotate:X,Press:W,on:l,off:m,each:e,merge:g,extend:f,inherit:h,bindFn:i,prefixed:t}),typeof define==eb&&define.amd?define(function(){return $}):typeof module!=fb&&module.exports?module.exports=$:a.Hammer=$}(window);
6
+ !function(a,b,c,d){"use strict";function e(a,b,c){return setTimeout(k(a,c),b)}function f(a,b,c){return Array.isArray(a)?(g(a,c[b],c),!0):!1}function g(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e<a.length;)b.call(c,a[e],e,a),e++;else for(e in a)a.hasOwnProperty(e)&&b.call(c,a[e],e,a)}function h(a,b,c){for(var e=Object.keys(b),f=0;f<e.length;)(!c||c&&a[e[f]]===d)&&(a[e[f]]=b[e[f]]),f++;return a}function i(a,b){return h(a,b,!0)}function j(a,b,c){var d,e=b.prototype;d=a.prototype=Object.create(e),d.constructor=a,d._super=e,c&&h(d,c)}function k(a,b){return function(){return a.apply(b,arguments)}}function l(a,b){return typeof a==kb?a.apply(b?b[0]||d:d,b):a}function m(a,b){return a===d?b:a}function n(a,b,c){g(r(b),function(b){a.addEventListener(b,c,!1)})}function o(a,b,c){g(r(b),function(b){a.removeEventListener(b,c,!1)})}function p(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function q(a,b){return a.indexOf(b)>-1}function r(a){return a.trim().split(/\s+/g)}function s(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;d<a.length;){if(c&&a[d][c]==b||!c&&a[d]===b)return d;d++}return-1}function t(a){return Array.prototype.slice.call(a,0)}function u(a,b,c){for(var d=[],e=[],f=0;f<a.length;){var g=b?a[f][b]:a[f];s(e,g)<0&&d.push(a[f]),e[f]=g,f++}return c&&(d=b?d.sort(function(a,c){return a[b]>c[b]}):d.sort()),d}function v(a,b){for(var c,e,f=b[0].toUpperCase()+b.slice(1),g=0;g<ib.length;){if(c=ib[g],e=c?c+f:b,e in a)return e;g++}return d}function w(){return ob++}function x(a){var b=a.ownerDocument;return b.defaultView||b.parentWindow}function y(a,b){var c=this;this.manager=a,this.callback=b,this.element=a.element,this.target=a.options.inputTarget,this.domHandler=function(b){l(a.options.enable,[a])&&c.handler(b)},this.init()}function z(a){var b,c=a.options.inputClass;return new(b=c?c:rb?N:sb?Q:qb?S:M)(a,A)}function A(a,b,c){var d=c.pointers.length,e=c.changedPointers.length,f=b&yb&&d-e===0,g=b&(Ab|Bb)&&d-e===0;c.isFirst=!!f,c.isFinal=!!g,f&&(a.session={}),c.eventType=b,B(a,c),a.emit("hammer.input",c),a.recognize(c),a.session.prevInput=c}function B(a,b){var c=a.session,d=b.pointers,e=d.length;c.firstInput||(c.firstInput=E(b)),e>1&&!c.firstMultiple?c.firstMultiple=E(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=F(d);b.timeStamp=nb(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=J(h,i),b.distance=I(h,i),C(c,b),b.offsetDirection=H(b.deltaX,b.deltaY),b.scale=g?L(g.pointers,d):1,b.rotation=g?K(g.pointers,d):0,D(c,b);var j=a.element;p(b.srcEvent.target,j)&&(j=b.srcEvent.target),b.target=j}function C(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(b.eventType===yb||f.eventType===Ab)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function D(a,b){var c,e,f,g,h=a.lastInterval||b,i=b.timeStamp-h.timeStamp;if(b.eventType!=Bb&&(i>xb||h.velocity===d)){var j=h.deltaX-b.deltaX,k=h.deltaY-b.deltaY,l=G(i,j,k);e=l.x,f=l.y,c=mb(l.x)>mb(l.y)?l.x:l.y,g=H(j,k),a.lastInterval=b}else c=h.velocity,e=h.velocityX,f=h.velocityY,g=h.direction;b.velocity=c,b.velocityX=e,b.velocityY=f,b.direction=g}function E(a){for(var b=[],c=0;c<a.pointers.length;)b[c]={clientX:lb(a.pointers[c].clientX),clientY:lb(a.pointers[c].clientY)},c++;return{timeStamp:nb(),pointers:b,center:F(b),deltaX:a.deltaX,deltaY:a.deltaY}}function F(a){var b=a.length;if(1===b)return{x:lb(a[0].clientX),y:lb(a[0].clientY)};for(var c=0,d=0,e=0;b>e;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:lb(c/b),y:lb(d/b)}}function G(a,b,c){return{x:b/a||0,y:c/a||0}}function H(a,b){return a===b?Cb:mb(a)>=mb(b)?a>0?Db:Eb:b>0?Fb:Gb}function I(a,b,c){c||(c=Kb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function J(a,b,c){c||(c=Kb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function K(a,b){return J(b[1],b[0],Lb)-J(a[1],a[0],Lb)}function L(a,b){return I(b[0],b[1],Lb)/I(a[0],a[1],Lb)}function M(){this.evEl=Nb,this.evWin=Ob,this.allow=!0,this.pressed=!1,y.apply(this,arguments)}function N(){this.evEl=Rb,this.evWin=Sb,y.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function O(){this.evTarget=Ub,this.evWin=Vb,this.started=!1,y.apply(this,arguments)}function P(a,b){var c=t(a.touches),d=t(a.changedTouches);return b&(Ab|Bb)&&(c=u(c.concat(d),"identifier",!0)),[c,d]}function Q(){this.evTarget=Xb,this.targetIds={},y.apply(this,arguments)}function R(a,b){var c=t(a.touches),d=this.targetIds;if(b&(yb|zb)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=t(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return p(a.target,i)}),b===yb)for(e=0;e<f.length;)d[f[e].identifier]=!0,e++;for(e=0;e<g.length;)d[g[e].identifier]&&h.push(g[e]),b&(Ab|Bb)&&delete d[g[e].identifier],e++;return h.length?[u(f.concat(h),"identifier",!0),h]:void 0}function S(){y.apply(this,arguments);var a=k(this.handler,this);this.touch=new Q(this.manager,a),this.mouse=new M(this.manager,a)}function T(a,b){this.manager=a,this.set(b)}function U(a){if(q(a,bc))return bc;var b=q(a,cc),c=q(a,dc);return b&&c?cc+" "+dc:b||c?b?cc:dc:q(a,ac)?ac:_b}function V(a){this.id=w(),this.manager=null,this.options=i(a||{},this.defaults),this.options.enable=m(this.options.enable,!0),this.state=ec,this.simultaneous={},this.requireFail=[]}function W(a){return a&jc?"cancel":a&hc?"end":a&gc?"move":a&fc?"start":""}function X(a){return a==Gb?"down":a==Fb?"up":a==Db?"left":a==Eb?"right":""}function Y(a,b){var c=b.manager;return c?c.get(a):a}function Z(){V.apply(this,arguments)}function $(){Z.apply(this,arguments),this.pX=null,this.pY=null}function _(){Z.apply(this,arguments)}function ab(){V.apply(this,arguments),this._timer=null,this._input=null}function bb(){Z.apply(this,arguments)}function cb(){Z.apply(this,arguments)}function db(){V.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function eb(a,b){return b=b||{},b.recognizers=m(b.recognizers,eb.defaults.preset),new fb(a,b)}function fb(a,b){b=b||{},this.options=i(b,eb.defaults),this.options.inputTarget=this.options.inputTarget||a,this.handlers={},this.session={},this.recognizers=[],this.element=a,this.input=z(this),this.touchAction=new T(this,this.options.touchAction),gb(this,!0),g(b.recognizers,function(a){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[3])},this)}function gb(a,b){var c=a.element;g(a.options.cssProps,function(a,d){c.style[v(c.style,d)]=b?a:""})}function hb(a,c){var d=b.createEvent("Event");d.initEvent(a,!0,!0),d.gesture=c,c.target.dispatchEvent(d)}var ib=["","webkit","moz","MS","ms","o"],jb=b.createElement("div"),kb="function",lb=Math.round,mb=Math.abs,nb=Date.now,ob=1,pb=/mobile|tablet|ip(ad|hone|od)|android/i,qb="ontouchstart"in a,rb=v(a,"PointerEvent")!==d,sb=qb&&pb.test(navigator.userAgent),tb="touch",ub="pen",vb="mouse",wb="kinect",xb=25,yb=1,zb=2,Ab=4,Bb=8,Cb=1,Db=2,Eb=4,Fb=8,Gb=16,Hb=Db|Eb,Ib=Fb|Gb,Jb=Hb|Ib,Kb=["x","y"],Lb=["clientX","clientY"];y.prototype={handler:function(){},init:function(){this.evEl&&n(this.element,this.evEl,this.domHandler),this.evTarget&&n(this.target,this.evTarget,this.domHandler),this.evWin&&n(x(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&o(this.element,this.evEl,this.domHandler),this.evTarget&&o(this.target,this.evTarget,this.domHandler),this.evWin&&o(x(this.element),this.evWin,this.domHandler)}};var Mb={mousedown:yb,mousemove:zb,mouseup:Ab},Nb="mousedown",Ob="mousemove mouseup";j(M,y,{handler:function(a){var b=Mb[a.type];b&yb&&0===a.button&&(this.pressed=!0),b&zb&&1!==a.which&&(b=Ab),this.pressed&&this.allow&&(b&Ab&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:vb,srcEvent:a}))}});var Pb={pointerdown:yb,pointermove:zb,pointerup:Ab,pointercancel:Bb,pointerout:Bb},Qb={2:tb,3:ub,4:vb,5:wb},Rb="pointerdown",Sb="pointermove pointerup pointercancel";a.MSPointerEvent&&(Rb="MSPointerDown",Sb="MSPointerMove MSPointerUp MSPointerCancel"),j(N,y,{handler:function(a){var b=this.store,c=!1,d=a.type.toLowerCase().replace("ms",""),e=Pb[d],f=Qb[a.pointerType]||a.pointerType,g=f==tb,h=s(b,a.pointerId,"pointerId");e&yb&&(0===a.button||g)?0>h&&(b.push(a),h=b.length-1):e&(Ab|Bb)&&(c=!0),0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Tb={touchstart:yb,touchmove:zb,touchend:Ab,touchcancel:Bb},Ub="touchstart",Vb="touchstart touchmove touchend touchcancel";j(O,y,{handler:function(a){var b=Tb[a.type];if(b===yb&&(this.started=!0),this.started){var c=P.call(this,a,b);b&(Ab|Bb)&&c[0].length-c[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:tb,srcEvent:a})}}});var Wb={touchstart:yb,touchmove:zb,touchend:Ab,touchcancel:Bb},Xb="touchstart touchmove touchend touchcancel";j(Q,y,{handler:function(a){var b=Wb[a.type],c=R.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:tb,srcEvent:a})}}),j(S,y,{handler:function(a,b,c){var d=c.pointerType==tb,e=c.pointerType==vb;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(Ab|Bb)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Yb=v(jb.style,"touchAction"),Zb=Yb!==d,$b="compute",_b="auto",ac="manipulation",bc="none",cc="pan-x",dc="pan-y";T.prototype={set:function(a){a==$b&&(a=this.compute()),Zb&&(this.manager.element.style[Yb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return g(this.manager.recognizers,function(b){l(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),U(a.join(" "))},preventDefaults:function(a){if(!Zb){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=q(d,bc),f=q(d,dc),g=q(d,cc);return e||f&&c&Hb||g&&c&Ib?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var ec=1,fc=2,gc=4,hc=8,ic=hc,jc=16,kc=32;V.prototype={defaults:{},set:function(a){return h(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(f(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=Y(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return f(a,"dropRecognizeWith",this)?this:(a=Y(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(f(a,"requireFailure",this))return this;var b=this.requireFail;return a=Y(a,this),-1===s(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(f(a,"dropRequireFailure",this))return this;a=Y(a,this);var b=s(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function b(b){c.manager.emit(c.options.event+(b?W(d):""),a)}var c=this,d=this.state;hc>d&&b(!0),b(),d>=hc&&b(!0)},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=kc)},canEmit:function(){for(var a=0;a<this.requireFail.length;){if(!(this.requireFail[a].state&(kc|ec)))return!1;a++}return!0},recognize:function(a){var b=h({},a);return l(this.options.enable,[this,b])?(this.state&(ic|jc|kc)&&(this.state=ec),this.state=this.process(b),void(this.state&(fc|gc|hc|jc)&&this.tryEmit(b))):(this.reset(),void(this.state=kc))},process:function(){},getTouchAction:function(){},reset:function(){}},j(Z,V,{defaults:{pointers:1},attrTest:function(a){var b=this.options.pointers;return 0===b||a.pointers.length===b},process:function(a){var b=this.state,c=a.eventType,d=b&(fc|gc),e=this.attrTest(a);return d&&(c&Bb||!e)?b|jc:d||e?c&Ab?b|hc:b&fc?b|gc:fc:kc}}),j($,Z,{defaults:{event:"pan",threshold:10,pointers:1,direction:Jb},getTouchAction:function(){var a=this.options.direction,b=[];return a&Hb&&b.push(dc),a&Ib&&b.push(cc),b},directionTest:function(a){var b=this.options,c=!0,d=a.distance,e=a.direction,f=a.deltaX,g=a.deltaY;return e&b.direction||(b.direction&Hb?(e=0===f?Cb:0>f?Db:Eb,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?Cb:0>g?Fb:Gb,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return Z.prototype.attrTest.call(this,a)&&(this.state&fc||!(this.state&fc)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this._super.emit.call(this,a)}}),j(_,Z,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[bc]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&fc)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),j(ab,V,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[_b]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,f=a.deltaTime>b.time;if(this._input=a,!d||!c||a.eventType&(Ab|Bb)&&!f)this.reset();else if(a.eventType&yb)this.reset(),this._timer=e(function(){this.state=ic,this.tryEmit()},b.time,this);else if(a.eventType&Ab)return ic;return kc},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===ic&&(a&&a.eventType&Ab?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=nb(),this.manager.emit(this.options.event,this._input)))}}),j(bb,Z,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[bc]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&fc)}}),j(cb,Z,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Hb|Ib,pointers:1},getTouchAction:function(){return $.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Hb|Ib)?b=a.velocity:c&Hb?b=a.velocityX:c&Ib&&(b=a.velocityY),this._super.attrTest.call(this,a)&&c&a.direction&&a.distance>this.options.threshold&&mb(b)>this.options.velocity&&a.eventType&Ab},emit:function(a){var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),j(db,V,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[ac]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,f=a.deltaTime<b.time;if(this.reset(),a.eventType&yb&&0===this.count)return this.failTimeout();if(d&&f&&c){if(a.eventType!=Ab)return this.failTimeout();var g=this.pTime?a.timeStamp-this.pTime<b.interval:!0,h=!this.pCenter||I(this.pCenter,a.center)<b.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,h&&g?this.count+=1:this.count=1,this._input=a;var i=this.count%b.taps;if(0===i)return this.hasRequireFailures()?(this._timer=e(function(){this.state=ic,this.tryEmit()},b.interval,this),fc):ic}return kc},failTimeout:function(){return this._timer=e(function(){this.state=kc},this.options.interval,this),kc},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==ic&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),eb.VERSION="2.0.4",eb.defaults={domEvents:!1,touchAction:$b,enable:!0,inputTarget:null,inputClass:null,preset:[[bb,{enable:!1}],[_,{enable:!1},["rotate"]],[cb,{direction:Hb}],[$,{direction:Hb},["swipe"]],[db],[db,{event:"doubletap",taps:2},["tap"]],[ab]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var lc=1,mc=2;fb.prototype={set:function(a){return h(this.options,a),a.touchAction&&this.touchAction.update(),a.inputTarget&&(this.input.destroy(),this.input.target=a.inputTarget,this.input.init()),this},stop:function(a){this.session.stopped=a?mc:lc},recognize:function(a){var b=this.session;if(!b.stopped){this.touchAction.preventDefaults(a);var c,d=this.recognizers,e=b.curRecognizer;(!e||e&&e.state&ic)&&(e=b.curRecognizer=null);for(var f=0;f<d.length;)c=d[f],b.stopped===mc||e&&c!=e&&!c.canRecognizeWith(e)?c.reset():c.recognize(a),!e&&c.state&(fc|gc|hc)&&(e=b.curRecognizer=c),f++}},get:function(a){if(a instanceof V)return a;for(var b=this.recognizers,c=0;c<b.length;c++)if(b[c].options.event==a)return b[c];return null},add:function(a){if(f(a,"add",this))return this;var b=this.get(a.options.event);return b&&this.remove(b),this.recognizers.push(a),a.manager=this,this.touchAction.update(),a},remove:function(a){if(f(a,"remove",this))return this;var b=this.recognizers;return a=this.get(a),b.splice(s(b,a),1),this.touchAction.update(),this},on:function(a,b){var c=this.handlers;return g(r(a),function(a){c[a]=c[a]||[],c[a].push(b)}),this},off:function(a,b){var c=this.handlers;return g(r(a),function(a){b?c[a].splice(s(c[a],b),1):delete c[a]}),this},emit:function(a,b){this.options.domEvents&&hb(a,b);var c=this.handlers[a]&&this.handlers[a].slice();if(c&&c.length){b.type=a,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var d=0;d<c.length;)c[d](b),d++}},destroy:function(){this.element&&gb(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},h(eb,{INPUT_START:yb,INPUT_MOVE:zb,INPUT_END:Ab,INPUT_CANCEL:Bb,STATE_POSSIBLE:ec,STATE_BEGAN:fc,STATE_CHANGED:gc,STATE_ENDED:hc,STATE_RECOGNIZED:ic,STATE_CANCELLED:jc,STATE_FAILED:kc,DIRECTION_NONE:Cb,DIRECTION_LEFT:Db,DIRECTION_RIGHT:Eb,DIRECTION_UP:Fb,DIRECTION_DOWN:Gb,DIRECTION_HORIZONTAL:Hb,DIRECTION_VERTICAL:Ib,DIRECTION_ALL:Jb,Manager:fb,Input:y,TouchAction:T,TouchInput:Q,MouseInput:M,PointerEventInput:N,TouchMouseInput:S,SingleTouchInput:O,Recognizer:V,AttrRecognizer:Z,Tap:db,Pan:$,Swipe:cb,Pinch:_,Rotate:bb,Press:ab,on:n,off:o,each:g,merge:i,extend:h,inherit:j,bindFn:k,prefixed:v}),typeof define==kb&&define.amd?define(function(){return eb}):"undefined"!=typeof module&&module.exports?module.exports=eb:a[c]=eb}(window,document,"Hammer");
9
7
  //# sourceMappingURL=hammer.min.map
@@ -1,8 +1,16 @@
1
- (function($, Hammer, dataAttr) {
1
+ (function(factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ define(['jquery', 'hammerjs'], factory);
4
+ } else if (typeof exports === 'object') {
5
+ factory(require('jquery'), require('hammerjs'));
6
+ } else {
7
+ factory(jQuery, Hammer);
8
+ }
9
+ }(function($, Hammer) {
2
10
  function hammerify(el, options) {
3
11
  var $el = $(el);
4
- if(!$el.data(dataAttr)) {
5
- $el.data(dataAttr, new Hammer($el[0], options));
12
+ if(!$el.data("hammer")) {
13
+ $el.data("hammer", new Hammer($el[0], options));
6
14
  }
7
15
  }
8
16
 
@@ -16,10 +24,10 @@
16
24
  Hammer.Manager.prototype.emit = (function(originalEmit) {
17
25
  return function(type, data) {
18
26
  originalEmit.call(this, type, data);
19
- jQuery(this.element).triggerHandler({
27
+ $(this.element).trigger({
20
28
  type: type,
21
29
  gesture: data
22
30
  });
23
31
  };
24
32
  })(Hammer.Manager.prototype.emit);
25
- })(jQuery, Hammer, "hammer");
33
+ }));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammerjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Pochet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.2.2
80
+ rubygems_version: 2.4.3
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: hammerjs packaged for Rails assets pipeline