Skip to content

Commit baeda65

Browse files
author
Ana
committed
Fix bug with rotation when add a value for threshold to avoid map being rotated and zoomed at the same time
1 parent 37206a3 commit baeda65

File tree

4 files changed

+72
-137
lines changed

4 files changed

+72
-137
lines changed

hammer.js

+67-132
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Hammer.JS - v2.0.8 - 2016-09-30
1+
/*! Hammer.JS - v2.0.8 - 2017-07-24
22
* http://hammerjs.github.io/
33
*
44
* Copyright (c) Jorik Tangelder;
@@ -237,118 +237,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
237237
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
238238
};
239239

240-
var asyncGenerator = function () {
241-
function AwaitValue(value) {
242-
this.value = value;
243-
}
244-
245-
function AsyncGenerator(gen) {
246-
var front, back;
247-
248-
function send(key, arg) {
249-
return new Promise(function (resolve, reject) {
250-
var request = {
251-
key: key,
252-
arg: arg,
253-
resolve: resolve,
254-
reject: reject,
255-
next: null
256-
};
257-
258-
if (back) {
259-
back = back.next = request;
260-
} else {
261-
front = back = request;
262-
resume(key, arg);
263-
}
264-
});
265-
}
266-
267-
function resume(key, arg) {
268-
try {
269-
var result = gen[key](arg);
270-
var value = result.value;
271-
272-
if (value instanceof AwaitValue) {
273-
Promise.resolve(value.value).then(function (arg) {
274-
resume("next", arg);
275-
}, function (arg) {
276-
resume("throw", arg);
277-
});
278-
} else {
279-
settle(result.done ? "return" : "normal", result.value);
280-
}
281-
} catch (err) {
282-
settle("throw", err);
283-
}
284-
}
285-
286-
function settle(type, value) {
287-
switch (type) {
288-
case "return":
289-
front.resolve({
290-
value: value,
291-
done: true
292-
});
293-
break;
294-
295-
case "throw":
296-
front.reject(value);
297-
break;
298-
299-
default:
300-
front.resolve({
301-
value: value,
302-
done: false
303-
});
304-
break;
305-
}
306240

307-
front = front.next;
308241

309-
if (front) {
310-
resume(front.key, front.arg);
311-
} else {
312-
back = null;
313-
}
314-
}
315242

316-
this._invoke = send;
317243

318-
if (typeof gen.return !== "function") {
319-
this.return = undefined;
320-
}
321-
}
322244

323-
if (typeof Symbol === "function" && Symbol.asyncIterator) {
324-
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
325-
return this;
326-
};
327-
}
328245

329-
AsyncGenerator.prototype.next = function (arg) {
330-
return this._invoke("next", arg);
331-
};
332246

333-
AsyncGenerator.prototype.throw = function (arg) {
334-
return this._invoke("throw", arg);
335-
};
336247

337-
AsyncGenerator.prototype.return = function (arg) {
338-
return this._invoke("return", arg);
339-
};
340248

341-
return {
342-
wrap: function (fn) {
343-
return function () {
344-
return new AsyncGenerator(fn.apply(this, arguments));
345-
};
346-
},
347-
await: function (value) {
348-
return new AwaitValue(value);
349-
}
350-
};
351-
}();
352249

353250
var classCallCheck = function (instance, Constructor) {
354251
if (!(instance instanceof Constructor)) {
@@ -374,7 +271,13 @@ var createClass = function () {
374271
};
375272
}();
376273

377-
var get = function get(object, property, receiver) {
274+
275+
276+
277+
278+
279+
280+
var get$1 = function get$1(object, property, receiver) {
378281
if (object === null) object = Function.prototype;
379282
var desc = Object.getOwnPropertyDescriptor(object, property);
380283

@@ -384,7 +287,7 @@ var get = function get(object, property, receiver) {
384287
if (parent === null) {
385288
return undefined;
386289
} else {
387-
return get(parent, property, receiver);
290+
return get$1(parent, property, receiver);
388291
}
389292
} else if ("value" in desc) {
390293
return desc.value;
@@ -415,6 +318,16 @@ var inherits = function (subClass, superClass) {
415318
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
416319
};
417320

321+
322+
323+
324+
325+
326+
327+
328+
329+
330+
418331
var possibleConstructorReturn = function (self, call) {
419332
if (!self) {
420333
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -423,6 +336,30 @@ var possibleConstructorReturn = function (self, call) {
423336
return call && (typeof call === "object" || typeof call === "function") ? call : self;
424337
};
425338

339+
340+
341+
var set$1 = function set$1(object, property, value, receiver) {
342+
var desc = Object.getOwnPropertyDescriptor(object, property);
343+
344+
if (desc === undefined) {
345+
var parent = Object.getPrototypeOf(object);
346+
347+
if (parent !== null) {
348+
set$1(parent, property, value, receiver);
349+
}
350+
} else if ("value" in desc && desc.writable) {
351+
desc.value = value;
352+
} else {
353+
var setter = desc.set;
354+
355+
if (setter !== undefined) {
356+
setter.call(receiver, value);
357+
}
358+
}
359+
360+
return value;
361+
};
362+
426363
var slicedToArray = function () {
427364
function sliceIterator(arr, i) {
428365
var _arr = [];
@@ -947,7 +884,7 @@ var RotateRecognizer = function (_AttrRecognizer) {
947884
}, {
948885
key: 'attrTest',
949886
value: function attrTest(input) {
950-
return get(RotateRecognizer.prototype.__proto__ || Object.getPrototypeOf(RotateRecognizer.prototype), 'attrTest', this).call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
887+
return get$1(RotateRecognizer.prototype.__proto__ || Object.getPrototypeOf(RotateRecognizer.prototype), 'attrTest', this).call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
951888
}
952889
}]);
953890
return RotateRecognizer;
@@ -983,7 +920,7 @@ var PinchRecognizer = function (_AttrRecognizer) {
983920
}, {
984921
key: 'attrTest',
985922
value: function attrTest(input) {
986-
return get(PinchRecognizer.prototype.__proto__ || Object.getPrototypeOf(PinchRecognizer.prototype), 'attrTest', this).call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
923+
return get$1(PinchRecognizer.prototype.__proto__ || Object.getPrototypeOf(PinchRecognizer.prototype), 'attrTest', this).call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
987924
}
988925
}, {
989926
key: 'emit',
@@ -992,7 +929,7 @@ var PinchRecognizer = function (_AttrRecognizer) {
992929
var inOut = input.scale < 1 ? 'in' : 'out';
993930
input.additionalEvent = this.options.event + inOut;
994931
}
995-
get(PinchRecognizer.prototype.__proto__ || Object.getPrototypeOf(PinchRecognizer.prototype), 'emit', this).call(this, input);
932+
get$1(PinchRecognizer.prototype.__proto__ || Object.getPrototypeOf(PinchRecognizer.prototype), 'emit', this).call(this, input);
996933
}
997934
}]);
998935
return PinchRecognizer;
@@ -1103,7 +1040,7 @@ var PanRecognizer = function (_AttrRecognizer) {
11031040
if (direction) {
11041041
input.additionalEvent = this.options.event + direction;
11051042
}
1106-
get(PanRecognizer.prototype.__proto__ || Object.getPrototypeOf(PanRecognizer.prototype), 'emit', this).call(this, input);
1043+
get$1(PanRecognizer.prototype.__proto__ || Object.getPrototypeOf(PanRecognizer.prototype), 'emit', this).call(this, input);
11071044
}
11081045
}]);
11091046
return PanRecognizer;
@@ -1152,7 +1089,7 @@ var SwipeRecognizer = function (_AttrRecognizer) {
11521089
velocity = input.overallVelocityY;
11531090
}
11541091

1155-
return get(SwipeRecognizer.prototype.__proto__ || Object.getPrototypeOf(SwipeRecognizer.prototype), 'attrTest', this).call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers === this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
1092+
return get$1(SwipeRecognizer.prototype.__proto__ || Object.getPrototypeOf(SwipeRecognizer.prototype), 'attrTest', this).call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers === this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
11561093
}
11571094
}, {
11581095
key: 'emit',
@@ -1783,7 +1720,7 @@ function getScale(start, end) {
17831720
* @return {Number} rotation
17841721
*/
17851722
function getRotation(start, end) {
1786-
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
1723+
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
17871724
}
17881725

17891726
/**
@@ -1849,8 +1786,8 @@ function computeInputData(manager, input) {
18491786
session.firstMultiple = false;
18501787
}
18511788

1852-
var firstInput = session.firstInput;
1853-
var firstMultiple = session.firstMultiple;
1789+
var firstInput = session.firstInput,
1790+
firstMultiple = session.firstMultiple;
18541791

18551792
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
18561793

@@ -2448,25 +2385,20 @@ function recordTouches(eventType, eventData) {
24482385
}
24492386

24502387
function setLastTouch(eventData) {
2451-
var _this2 = this;
2452-
2453-
var _eventData$changedPoi = slicedToArray(eventData.changedPointers, 1);
2454-
2455-
var touch = _eventData$changedPoi[0];
2388+
var _eventData$changedPoi = slicedToArray(eventData.changedPointers, 1),
2389+
touch = _eventData$changedPoi[0];
24562390

24572391
if (touch.identifier === this.primaryTouch) {
2458-
(function () {
2459-
var lastTouch = { x: touch.clientX, y: touch.clientY };
2460-
_this2.lastTouches.push(lastTouch);
2461-
var lts = _this2.lastTouches;
2462-
var removeLastTouch = function removeLastTouch() {
2463-
var i = lts.indexOf(lastTouch);
2464-
if (i > -1) {
2465-
lts.splice(i, 1);
2466-
}
2467-
};
2468-
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
2469-
})();
2392+
var lastTouch = { x: touch.clientX, y: touch.clientY };
2393+
this.lastTouches.push(lastTouch);
2394+
var lts = this.lastTouches;
2395+
var removeLastTouch = function removeLastTouch() {
2396+
var i = lts.indexOf(lastTouch);
2397+
if (i > -1) {
2398+
lts.splice(i, 1);
2399+
}
2400+
};
2401+
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
24702402
}
24712403
}
24722404

@@ -3226,6 +3158,9 @@ assign$1(Hammer, {
32263158
removeEventListeners: removeEventListeners
32273159
});
32283160

3161+
var freeGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}; // jshint ignore:line
3162+
freeGlobal.Hammer = Hammer;
3163+
32293164
/* jshint ignore:start */
32303165
if (typeof define === 'function' && define.amd) {
32313166
define(function () {
@@ -3237,4 +3172,4 @@ if (typeof define === 'function' && define.amd) {
32373172
window[exportName] = Hammer;
32383173
}
32393174
/* jshint ignore:end */
3240-
})(window, document, 'Hammer');
3175+
})(window, document, 'Hammer');

hammer.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hammer.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/inputjs/get-rotation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import { PROPS_CLIENT_XY } from './input-consts';
99
* @return {Number} rotation
1010
*/
1111
export default function getRotation(start, end) {
12-
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
12+
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
1313
}

0 commit comments

Comments
 (0)