easy-gestures 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +11 -0
- package/README.md +133 -0
- package/bin/main.js +15 -0
- package/example.js +34433 -0
- package/index.html +52 -0
- package/lib/constants.js +42 -0
- package/lib/customEventTypes.js +74 -0
- package/lib/example/preamble.js +10 -0
- package/lib/example/view.js +233 -0
- package/lib/example.js +19 -0
- package/lib/index.js +18 -0
- package/lib/mixins/touch.js +477 -0
- package/lib/position/relative.js +97 -0
- package/lib/position.js +101 -0
- package/lib/preamble.js +10 -0
- package/lib/selectors.js +26 -0
- package/lib/utilities/positions.js +143 -0
- package/license.txt +48 -0
- package/package.json +38 -0
- package/src/constants.js +10 -0
- package/src/customEventTypes.js +17 -0
- package/src/example/preamble.js +7 -0
- package/src/example/view.js +85 -0
- package/src/example.js +22 -0
- package/src/index.js +3 -0
- package/src/mixins/touch.js +754 -0
- package/src/position/relative.js +63 -0
- package/src/position.js +74 -0
- package/src/preamble.js +7 -0
- package/src/selectors.js +5 -0
- package/src/utilities/positions.js +127 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return RelativePosition;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _constants = require("../constants");
|
|
12
|
+
function _class_call_check(instance, Constructor) {
|
|
13
|
+
if (!(instance instanceof Constructor)) {
|
|
14
|
+
throw new TypeError("Cannot call a class as a function");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function _defineProperties(target, props) {
|
|
18
|
+
for(var i = 0; i < props.length; i++){
|
|
19
|
+
var descriptor = props[i];
|
|
20
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
21
|
+
descriptor.configurable = true;
|
|
22
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
23
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
27
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
28
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
29
|
+
return Constructor;
|
|
30
|
+
}
|
|
31
|
+
var RelativePosition = /*#__PURE__*/ function() {
|
|
32
|
+
function RelativePosition(top, left, time, speed, magnitude, direction) {
|
|
33
|
+
_class_call_check(this, RelativePosition);
|
|
34
|
+
this.top = top;
|
|
35
|
+
this.left = left;
|
|
36
|
+
this.time = time;
|
|
37
|
+
this.speed = speed;
|
|
38
|
+
this.magnitude = magnitude;
|
|
39
|
+
this.direction = direction;
|
|
40
|
+
}
|
|
41
|
+
_create_class(RelativePosition, [
|
|
42
|
+
{
|
|
43
|
+
key: "getTop",
|
|
44
|
+
value: function getTop() {
|
|
45
|
+
return this.top;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "getLeft",
|
|
50
|
+
value: function getLeft() {
|
|
51
|
+
return this.left;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "getTime",
|
|
56
|
+
value: function getTime() {
|
|
57
|
+
return this.time;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "getSpeed",
|
|
62
|
+
value: function getSpeed() {
|
|
63
|
+
return this.speed;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "getMagnitude",
|
|
68
|
+
value: function getMagnitude() {
|
|
69
|
+
return this.magnitude;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
key: "getDirection",
|
|
74
|
+
value: function getDirection() {
|
|
75
|
+
return this.direction;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
], [
|
|
79
|
+
{
|
|
80
|
+
key: "fromFirstPositionAndSecondPosition",
|
|
81
|
+
value: function fromFirstPositionAndSecondPosition(firstPosition, secondPosition) {
|
|
82
|
+
var position = secondPosition.minus(firstPosition), top = position.getTop(), left = position.getLeft(), time = position.getTime(), magnitude = Math.sqrt(top * top + left * left), speed = time === 0 ? 0 : magnitude / time;
|
|
83
|
+
var direction;
|
|
84
|
+
if (left === 0) {
|
|
85
|
+
direction = top < 0 ? +_constants.PI / 2 : -_constants.PI / 2;
|
|
86
|
+
} else {
|
|
87
|
+
direction = Math.atan2(-top, left);
|
|
88
|
+
}
|
|
89
|
+
var relativePosition = new RelativePosition(top, left, time, speed, magnitude, direction);
|
|
90
|
+
return relativePosition;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]);
|
|
94
|
+
return RelativePosition;
|
|
95
|
+
}();
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wb3NpdGlvbi9yZWxhdGl2ZS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHsgUEkgfSBmcm9tIFwiLi4vY29uc3RhbnRzXCI7XG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFJlbGF0aXZlUG9zaXRpb24ge1xuICBjb25zdHJ1Y3Rvcih0b3AsIGxlZnQsIHRpbWUsIHNwZWVkLCBtYWduaXR1ZGUsIGRpcmVjdGlvbikge1xuICAgIHRoaXMudG9wID0gdG9wO1xuICAgIHRoaXMubGVmdCA9IGxlZnQ7XG4gICAgdGhpcy50aW1lID0gdGltZTtcbiAgICB0aGlzLnNwZWVkID0gc3BlZWQ7XG4gICAgdGhpcy5tYWduaXR1ZGUgPSBtYWduaXR1ZGU7XG4gICAgdGhpcy5kaXJlY3Rpb24gPSBkaXJlY3Rpb247XG4g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ZCxZQUFZWSxLQUFLRyxLQUFLLENBQUMsQ0FBQ3BCLEtBQUtDO2dCQUMvQjtnQkFFQSxJQUFNb0IsbUJBQW1CLElBdERSdEIsaUJBc0Q2QkMsS0FBS0MsTUFBTUMsTUFBTUMsT0FBT0MsV0FBV0M7Z0JBRWpGLE9BQU9nQjtZQUNUOzs7V0F6RG1CdEIifQ==
|
package/lib/position.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Position;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _class_call_check(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _defineProperties(target, props) {
|
|
17
|
+
for(var i = 0; i < props.length; i++){
|
|
18
|
+
var descriptor = props[i];
|
|
19
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
20
|
+
descriptor.configurable = true;
|
|
21
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
22
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
26
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
27
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
28
|
+
return Constructor;
|
|
29
|
+
}
|
|
30
|
+
var Position = /*#__PURE__*/ function() {
|
|
31
|
+
function Position(top, left, time, identifier) {
|
|
32
|
+
_class_call_check(this, Position);
|
|
33
|
+
this.top = top;
|
|
34
|
+
this.left = left;
|
|
35
|
+
this.time = time;
|
|
36
|
+
this.identifier = identifier;
|
|
37
|
+
}
|
|
38
|
+
_create_class(Position, [
|
|
39
|
+
{
|
|
40
|
+
key: "getTop",
|
|
41
|
+
value: function getTop() {
|
|
42
|
+
return this.top;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "getLeft",
|
|
47
|
+
value: function getLeft() {
|
|
48
|
+
return this.left;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "getTime",
|
|
53
|
+
value: function getTime() {
|
|
54
|
+
return this.time;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "getIdentifier",
|
|
59
|
+
value: function getIdentifier() {
|
|
60
|
+
return this.identifier;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "minus",
|
|
65
|
+
value: function minus(position) {
|
|
66
|
+
var positionTop = position.getTop(), positionLeft = position.getLeft(), positionTime = position.getTime(), top = this.top - positionTop, left = this.left - positionLeft, time = this.time - positionTime, identifier = this.identifier;
|
|
67
|
+
position = new Position(top, left, time, identifier); ///
|
|
68
|
+
return position;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: "match",
|
|
73
|
+
value: function match(position) {
|
|
74
|
+
var identifier = position.getIdentifier(), matches = this.identifier === identifier;
|
|
75
|
+
return matches;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
], [
|
|
79
|
+
{
|
|
80
|
+
key: "fromTouch",
|
|
81
|
+
value: function fromTouch(touch) {
|
|
82
|
+
var pageX = touch.pageX, pageY = touch.pageY, identifier = touch.identifier, top = pageY, left = pageX, time = getTime(), position = new Position(top, left, time, identifier);
|
|
83
|
+
return position;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: "fromMouseEvent",
|
|
88
|
+
value: function fromMouseEvent(mouseEvent) {
|
|
89
|
+
var pageX = mouseEvent.pageX, pageY = mouseEvent.pageY, top = pageY, left = pageX, time = getTime(), identifier = null, position = new Position(top, left, time, identifier);
|
|
90
|
+
return position;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]);
|
|
94
|
+
return Position;
|
|
95
|
+
}();
|
|
96
|
+
function getTime() {
|
|
97
|
+
var time = Date.now(); ///
|
|
98
|
+
return time;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wb3NpdGlvbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgUG9zaXRpb24ge1xuICBjb25zdHJ1Y3Rvcih0b3AsIGxlZnQsIHRpbWUsIGlkZW50aWZpZXIpIHtcbiAgICB0aGlzLnRvcCA9IHRvcDtcbiAgICB0aGlzLmxlZnQgPSBsZWZ0O1xuICAgIHRoaXMudGltZSA9IHRpbWU7XG4gICAgdGhpcy5pZGVudGlmaWVyID0gaWRlbnRpZmllcjtcbiAgfVxuXG4gIGdldFRvcCgpIHtcbiAgICByZXR1cm4gdGhpcy50b3A7XG4gIH1cblxuICBnZXRMZWZ0KCkge1xuICAgIHJldHVybiB0aGlzLmxlZnQ7XG4gIH1cblxuICBnZXRUaW1lKCkge1xuICAgIHJldHVybiB0aGlzLnRpbWU7XG4gIH1cblxuICBnZXRJZGVudGlmaWVyKCkge1xuICAgIHJldHVybiB0aGlzLmlkZW50aWZpZXI7XG4gIH1cblxuICBtaW51cyhwb3NpdGlvbikge1xuICAgIGNvbnN0IHBvc2l0aW9uVG9wID0gcG9zaXRpb24uZ2V0VG9wKCksXG4gICAgICAgICAgcG9zaXRpb25MZWZ0ID0gcG9zaXRpb24uZ2V0TGVmdCgpLFxuICAgICAgICAgIHBvc2l0aW9uVGltZSA9IHBvc2l0aW9uLmdldFRpbWUoKSxcbiAgICAgICAgICB0b3AgPSB0aGlzLnRvcC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9DLE9BQU9NO1lBQ1Q7OztZQUVPVSxLQUFBQTttQkFBUCxTQUFPQSxlQUFlQyxVQUFVO2dCQUM5QixJQUFRSCxRQUFpQkcsV0FBakJILE9BQU9DLFFBQVVFLFdBQVZGLE9BQ1RsQixNQUFNa0IsT0FDTmpCLE9BQU9nQixPQUNQZixPQUFPSSxXQUNQSCxhQUFhLE1BQ2JNLFdBQVcsSUE3REFWLFNBNkRhQyxLQUFLQyxNQUFNQyxNQUFNQztnQkFFL0MsT0FBT007WUFDVDs7O1dBaEVtQlY7O0FBbUVyQixTQUFTTztJQUNQLElBQU1KLE9BQU9tQixLQUFLQyxHQUFHLElBQUssR0FBRztJQUU3QixPQUFPcEI7QUFDVCJ9
|
package/lib/preamble.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _easy = require("easy");
|
|
6
|
+
Object.assign(globalThis, {
|
|
7
|
+
React: _easy.React
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wcmVhbWJsZS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHsgUmVhY3QgfSBmcm9tIFwiZWFzeVwiO1xuXG5PYmplY3QuYXNzaWduKGdsb2JhbFRoaXMsIHtcbiAgUmVhY3Rcbn0pO1xuIl0sIm5hbWVzIjpbIk9iamVjdCIsImFzc2lnbiIsImdsb2JhbFRoaXMiLCJSZWFjdCJdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7b0JBRXNCO0FBRXRCQSxPQUFPQyxNQUFNLENBQUNDLFlBQVk7SUFDeEJDLE9BQUFBLFdBQUs7QUFDUCJ9
|
package/lib/selectors.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get DIVS_SELECTOR () {
|
|
13
|
+
return DIVS_SELECTOR;
|
|
14
|
+
},
|
|
15
|
+
get DIV_SELECTOR () {
|
|
16
|
+
return DIV_SELECTOR;
|
|
17
|
+
},
|
|
18
|
+
get LOADING_DIV_SELECTOR () {
|
|
19
|
+
return LOADING_DIV_SELECTOR;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var DIV_SELECTOR = "div";
|
|
23
|
+
var DIVS_SELECTOR = "body > div:not(.loading)"; ///
|
|
24
|
+
var LOADING_DIV_SELECTOR = "body > div.loading";
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9zZWxlY3RvcnMuanMiXSwic291cmNlc0NvbnRlbnQiOlsiXCJ1c2Ugc3RyaWN0XCI7XG5cbmV4cG9ydCBjb25zdCBESVZfU0VMRUNUT1IgPSBcImRpdlwiO1xuZXhwb3J0IGNvbnN0IERJVlNfU0VMRUNUT1IgPSBcImJvZHkgPiBkaXY6bm90KC5sb2FkaW5nKVwiOyAvLy9cbmV4cG9ydCBjb25zdCBMT0FESU5HX0RJVl9TRUxFQ1RPUiA9IFwiYm9keSA+IGRpdi5sb2FkaW5nXCI7XG4iXSwibmFtZXMiOlsiRElWU19TRUxFQ1RPUiIsIkRJVl9TRUxFQ1RPUiIsIkxPQURJTkdfRElWX1NFTEVDVE9SIl0sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7UUFHYUE7ZUFBQUE7O1FBREFDO2VBQUFBOztRQUVBQztlQUFBQTs7O0FBRk4sSUFBTUQsZUFBZTtBQUNyQixJQUFNRCxnQkFBZ0IsNEJBQTRCLEdBQUc7QUFDckQsSUFBTUUsdUJBQXVCIn0=
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get filterPositions () {
|
|
13
|
+
return filterPositions;
|
|
14
|
+
},
|
|
15
|
+
get matchPositions () {
|
|
16
|
+
return matchPositions;
|
|
17
|
+
},
|
|
18
|
+
get positionsFromMouseEvent () {
|
|
19
|
+
return positionsFromMouseEvent;
|
|
20
|
+
},
|
|
21
|
+
get positionsFromTouchEvent () {
|
|
22
|
+
return positionsFromTouchEvent;
|
|
23
|
+
},
|
|
24
|
+
get sortPositions () {
|
|
25
|
+
return sortPositions;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var _necessary = require("necessary");
|
|
29
|
+
var _position = /*#__PURE__*/ _interop_require_default(require("../position"));
|
|
30
|
+
function _array_like_to_array(arr, len) {
|
|
31
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
32
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
33
|
+
return arr2;
|
|
34
|
+
}
|
|
35
|
+
function _array_without_holes(arr) {
|
|
36
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
37
|
+
}
|
|
38
|
+
function _interop_require_default(obj) {
|
|
39
|
+
return obj && obj.__esModule ? obj : {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function _iterable_to_array(iter) {
|
|
44
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
45
|
+
}
|
|
46
|
+
function _non_iterable_spread() {
|
|
47
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
48
|
+
}
|
|
49
|
+
function _to_consumable_array(arr) {
|
|
50
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
51
|
+
}
|
|
52
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
53
|
+
if (!o) return;
|
|
54
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
55
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
56
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
57
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
58
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
59
|
+
}
|
|
60
|
+
var clear = _necessary.arrayUtilities.clear, filter = _necessary.arrayUtilities.filter;
|
|
61
|
+
function sortPositions(positionsA, positionsB) {
|
|
62
|
+
var positionAMap = positionsA.reduce(function(positionAMap, positionA) {
|
|
63
|
+
var identifier = positionA.getIdentifier();
|
|
64
|
+
positionAMap[identifier] = positionA;
|
|
65
|
+
return positionAMap;
|
|
66
|
+
}, {});
|
|
67
|
+
clear(positionsA);
|
|
68
|
+
positionsB.forEach(function(positionB) {
|
|
69
|
+
var identifier = positionB.getIdentifier(), positionA = positionAMap[identifier];
|
|
70
|
+
positionsA.push(positionA);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function matchPositions(positionsA, positionsB) {
|
|
74
|
+
var positionsMatch = false;
|
|
75
|
+
var positionsALength = positionsA.length, positionsBLength = positionsB.length;
|
|
76
|
+
if (positionsALength === positionsBLength) {
|
|
77
|
+
var identifiersA = identifiersFromPositions(positionsA), identifiersB = identifiersFromPositions(positionsB);
|
|
78
|
+
identifiersA.sort();
|
|
79
|
+
identifiersB.sort();
|
|
80
|
+
var identifiersMatch = identifiersA.every(function(identifierA, index) {
|
|
81
|
+
var identifierB = identifiersB[index];
|
|
82
|
+
if (identifierA === identifierB) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
positionsMatch = identifiersMatch; ///
|
|
87
|
+
}
|
|
88
|
+
return positionsMatch;
|
|
89
|
+
}
|
|
90
|
+
function filterPositions(positionsA, positionsB) {
|
|
91
|
+
filter(positionsA, function(positionA) {
|
|
92
|
+
var matches = positionsB.some(function(positionB) {
|
|
93
|
+
var matches = positionA.match(positionB);
|
|
94
|
+
if (matches) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (!matches) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function positionsFromMouseEvent(mouseEvent) {
|
|
104
|
+
var position = _position.default.fromMouseEvent(mouseEvent), positions = [
|
|
105
|
+
position
|
|
106
|
+
];
|
|
107
|
+
return positions;
|
|
108
|
+
}
|
|
109
|
+
function positionsFromTouchEvent(touchEvent) {
|
|
110
|
+
var changed = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
111
|
+
var touchesNodeList;
|
|
112
|
+
if (changed) {
|
|
113
|
+
var ref;
|
|
114
|
+
ref = touchEvent, touchesNodeList = ref.changedTouches, ref;
|
|
115
|
+
} else {
|
|
116
|
+
var ref1;
|
|
117
|
+
ref1 = touchEvent, touchesNodeList = ref1.touches, ref1;
|
|
118
|
+
}
|
|
119
|
+
var touches = _to_consumable_array(touchesNodeList), positions = touches.map(function(touch) {
|
|
120
|
+
var position = _position.default.fromTouch(touch);
|
|
121
|
+
return position;
|
|
122
|
+
});
|
|
123
|
+
compressPositions(positions);
|
|
124
|
+
return positions;
|
|
125
|
+
}
|
|
126
|
+
function compressPositions(positions) {
|
|
127
|
+
var positionMap = positions.reduce(function(positionMap, position) {
|
|
128
|
+
var identifier = position.getIdentifier();
|
|
129
|
+
positionMap[identifier] = position;
|
|
130
|
+
return positionMap;
|
|
131
|
+
}, {});
|
|
132
|
+
positions = Object.values(positionMap);
|
|
133
|
+
return positions;
|
|
134
|
+
}
|
|
135
|
+
function identifiersFromPositions(positions) {
|
|
136
|
+
var identifiers = positions.map(function(position) {
|
|
137
|
+
var identifier = position.getIdentifier();
|
|
138
|
+
return identifier;
|
|
139
|
+
});
|
|
140
|
+
return identifiers;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcG9zaXRpb25zLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuXG5pbXBvcnQgeyBhcnJheVV0aWxpdGllcyB9IGZyb20gXCJuZWNlc3NhcnlcIjtcblxuaW1wb3J0IFBvc2l0aW9uIGZyb20gXCIuLi9wb3NpdGlvblwiO1xuXG5jb25zdCB7IGNsZWFyLCBmaWx0ZXIgfSA9IGFycmF5VXRpbGl0aWVzO1xuXG5leHBvcnQgZnVuY3Rpb24gc29ydFBvc2l0aW9ucyhwb3NpdGlvbnNBLCBwb3NpdGlvbnNCKSB7XG4gIGNvbnN0IHBvc2l0aW9uQU1hcCA9IHBvc2l0aW9uc0EucmVkdWNlKChwb3NpdGlvbkFNYXAsIHBvc2l0aW9uQSkgPT4ge1xuICAgIGNvbnN0IGlkZW50aWZpZXIgPSBwb3NpdGlvbkEuZ2V0SWRlbnRpZmllcigpO1xuXG4gICAgcG9zaXRpb25BTWFwW2lkZW50aWZpZXJdID0gcG9zaXRpb25BO1xuXG4gICAgcmV0dXJuIHBvc2l0aW9uQU1hcDtcbiAgfSwge30p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ixhQUFhO1FBRXpDa0MsV0FBVyxDQUFDbkMsV0FBVyxHQUFHc0I7UUFFMUIsT0FBT2E7SUFDVCxHQUFHLENBQUM7SUFFSlYsWUFBWVcsT0FBT0MsTUFBTSxDQUFDRjtJQUUxQixPQUFPVjtBQUNUO0FBRUEsU0FBU2YseUJBQXlCZSxTQUFTO0lBQ3pDLElBQU1hLGNBQWNiLFVBQVVNLEdBQUcsQ0FBQyxTQUFDVDtRQUNqQyxJQUFNdEIsYUFBYXNCLFNBQVNyQixhQUFhO1FBRXpDLE9BQU9EO0lBQ1Q7SUFFQSxPQUFPc0M7QUFDVCJ9
|
package/license.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
MIT And Anti-996 Licenses
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 James Smith
|
|
4
|
+
|
|
5
|
+
These licenses shall be included in all copies or substantial portions of
|
|
6
|
+
this software and associated documentation files (the "Software").
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this Software, to deal in the Software without restriction, including
|
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
12
|
+
persons to whom the Software is furnished to do so, subject to the following
|
|
13
|
+
conditions:
|
|
14
|
+
|
|
15
|
+
1. The individual or the legal entity must conspicuously display,
|
|
16
|
+
without modification, this License and the notice on each redistributed
|
|
17
|
+
or derivative copy of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
2. The individual or the legal entity must strictly comply with all
|
|
20
|
+
applicable laws, regulations, rules and standards of the jurisdiction
|
|
21
|
+
relating to labor and employment where the individual is physically
|
|
22
|
+
located or where the individual was born or naturalized; or where the
|
|
23
|
+
legal entity is registered or is operating (whichever is stricter). In
|
|
24
|
+
case that the jurisdiction has no such laws, regulations, rules and
|
|
25
|
+
standards or its laws, regulations, rules and standards are
|
|
26
|
+
unenforceable, the individual or the legal entity are required to
|
|
27
|
+
comply with Core International Labor Standards.
|
|
28
|
+
|
|
29
|
+
3. The individual or the legal entity shall not induce, suggest or force
|
|
30
|
+
its employee(s), whether full-time or part-time, or its independent
|
|
31
|
+
contractor(s), in any methods, to agree in oral or written form, to
|
|
32
|
+
directly or indirectly restrict, weaken or relinquish his or her
|
|
33
|
+
rights or remedies under such laws, regulations, rules and standards
|
|
34
|
+
relating to labor and employment as mentioned above, no matter whether
|
|
35
|
+
such written or oral agreements are enforceable under the laws of the
|
|
36
|
+
said jurisdiction, nor shall such individual or the legal entity
|
|
37
|
+
limit, in any methods, the rights of its employee(s) or independent
|
|
38
|
+
contractor(s) from reporting or complaining to the copyright holder or
|
|
39
|
+
relevant authorities monitoring the compliance of the license about
|
|
40
|
+
its violation(s) of the said license.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "easy-gestures",
|
|
3
|
+
"author": "James Smith",
|
|
4
|
+
"version": "2.0.5",
|
|
5
|
+
"license": "MIT, Anti-996",
|
|
6
|
+
"homepage": "https://github.com/djalbat/easy-gestures",
|
|
7
|
+
"description": "Touch gestures for web applications.",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/djalbat/easy-gestures"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"easy": "^24.0.4",
|
|
14
|
+
"easy-drag-and-drop": "^1.3.280",
|
|
15
|
+
"easy-with-style": "^3.0.528"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@swc/core": "1.13.20",
|
|
19
|
+
"esbuild": "0.11.14",
|
|
20
|
+
"express": "^4.17.1",
|
|
21
|
+
"lively-cli": "^2.0.77",
|
|
22
|
+
"watchful-cli": "^1.7.63"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"start": "node ./bin/main.js",
|
|
26
|
+
"clean": "rm -rf ./lib",
|
|
27
|
+
"watchful": "watchful -m --transpiler=swc --bundler=esbuild --source-directory=./src --lib-directory=./lib --entry-file=example.js --bundle-file=./example.js --wait=100",
|
|
28
|
+
"batch": "npm run watchful batch --",
|
|
29
|
+
"batch-debug": "npm run watchful batch -- --debug",
|
|
30
|
+
"incremental": "npm run watchful incremental --",
|
|
31
|
+
"incremental-debug": "npm run watchful incremental -- --debug",
|
|
32
|
+
"build": "npm run clean && npm run batch",
|
|
33
|
+
"build-debug": "npm run clean && npm run batch-debug",
|
|
34
|
+
"watch": "npm run clean && npm run batch && npm run incremental",
|
|
35
|
+
"watch-debug": "npm run clean && npm run batch-debug && npm run incremental-debug"
|
|
36
|
+
},
|
|
37
|
+
"main": "./lib/index.js"
|
|
38
|
+
}
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const { PI } = Math;
|
|
4
|
+
|
|
5
|
+
export const TAP_DELAY = 250;
|
|
6
|
+
export const PRESS_DELAY = 750;
|
|
7
|
+
export const PI_OVER_TWO = PI / 2;
|
|
8
|
+
export const MAXIMUM_SPREAD = PI / 4;
|
|
9
|
+
export const MAXIMUM_TAP_TIME = 125;
|
|
10
|
+
export const MINIMUM_SWIPE_SPEED = 1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const PRESS_CUSTOM_EVENT_TYPE = "press";
|
|
4
|
+
export const DRAG_UP_CUSTOM_EVENT_TYPE = "drag-up";
|
|
5
|
+
export const DRAG_DOWN_CUSTOM_EVENT_TYPE = "drag-down";
|
|
6
|
+
export const DRAG_LEFT_CUSTOM_EVENT_TYPE = "drag-left";
|
|
7
|
+
export const DRAG_RIGHT_CUSTOM_EVENT_TYPE = "drag-right";
|
|
8
|
+
export const DRAG_START_CUSTOM_EVENT_TYPE = "drag-start";
|
|
9
|
+
export const SWIPE_UP_CUSTOM_EVENT_TYPE = "swipe-up";
|
|
10
|
+
export const SWIPE_DOWN_CUSTOM_EVENT_TYPE = "swipe-down";
|
|
11
|
+
export const SWIPE_LEFT_CUSTOM_EVENT_TYPE = "swipe-left";
|
|
12
|
+
export const SWIPE_RIGHT_CUSTOM_EVENT_TYPE = "swipe-right";
|
|
13
|
+
export const PINCH_MOVE_CUSTOM_EVENT_TYPE = "pinch-move";
|
|
14
|
+
export const PINCH_START_CUSTOM_EVENT_TYPE = "pinch-start";
|
|
15
|
+
export const PINCH_STOP_CUSTOM_EVENT_TYPE = "pinch-stop";
|
|
16
|
+
export const SINGLE_TAP_CUSTOM_EVENT_TYPE = "single-tap";
|
|
17
|
+
export const DOUBLE_TAP_CUSTOM_EVENT_TYPE = "double-tap";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
import { touchMixins } from "../index"; ///
|
|
7
|
+
|
|
8
|
+
class View extends Element {
|
|
9
|
+
singleTapCustomHandler = (event, element, top, left) => {
|
|
10
|
+
console.log("single tap")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
doubleTapCustomHandler = (event, element, top, left) => {
|
|
14
|
+
console.log("double tap")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
pinchStartCustomHandler = (event, element) => {
|
|
18
|
+
console.log("pinch start")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
pinchMoveCustomHandler = (event, element, ratio) => {
|
|
22
|
+
console.log("pinch move", ratio)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
swipeRightCustomHandler = (event, element, top, left, speed) => {
|
|
26
|
+
console.log("swipe right", speed)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
swipeLeftCustomHandler = (event, element, top, left, speed) => {
|
|
30
|
+
console.log("swipe left", speed)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
dragDownCustomHandler = (event, element, top, left) => {
|
|
34
|
+
console.log("drag down", top)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
dragUpCustomHandler = (event, element, top, left) => {
|
|
38
|
+
console.log("drag up", top)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
didMount() {
|
|
42
|
+
this.onCustomDragUp(this.dragUpCustomHandler);
|
|
43
|
+
this.onCustomDragDown(this.dragDownCustomHandler);
|
|
44
|
+
this.onCustomSwipeLeft(this.swipeLeftCustomHandler);
|
|
45
|
+
this.onCustomSwipeRight(this.swipeRightCustomHandler);
|
|
46
|
+
this.onCustomPinchMove(this.pinchMoveCustomHandler);
|
|
47
|
+
this.onCustomPinchStart(this.pinchStartCustomHandler);
|
|
48
|
+
this.onCustomSingleTap(this.singleTapCustomHandler);
|
|
49
|
+
this.onCustomDoubleTap(this.doubleTapCustomHandler);
|
|
50
|
+
|
|
51
|
+
this.enableTouch();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
willUnmount() {
|
|
55
|
+
this.disableTouch();
|
|
56
|
+
|
|
57
|
+
this.offCustomDragUp(this.dragUpCustomHandler);
|
|
58
|
+
this.offCustomDragDown(this.dragDownCustomHandler);
|
|
59
|
+
this.offCustomSwipeLeft(this.swipeLeftCustomHandler);
|
|
60
|
+
this.offCustomSwipeRight(this.swipeRightCustomHandler);
|
|
61
|
+
this.offCustomPinchMove(this.pinchMoveCustomHandler);
|
|
62
|
+
this.offCustomPinchStart(this.pinchStartCustomHandler);
|
|
63
|
+
this.offCustomSingleTap(this.singleTapCustomHandler);
|
|
64
|
+
this.offCustomDoubleTap(this.doubleTapCustomHandler);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static tagName = "div";
|
|
68
|
+
|
|
69
|
+
static defaultProperties = {
|
|
70
|
+
className: "view"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Object.assign(View.prototype, touchMixins);
|
|
75
|
+
|
|
76
|
+
export default withStyle(View)`
|
|
77
|
+
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
touch-action: none;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
|
|
85
|
+
`;
|
package/src/example.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import "./example/preamble";
|
|
4
|
+
|
|
5
|
+
import withStyle from "easy-with-style"; ///
|
|
6
|
+
|
|
7
|
+
import { Body } from "easy";
|
|
8
|
+
|
|
9
|
+
import View from "./example/view";
|
|
10
|
+
|
|
11
|
+
const { renderStyles } = withStyle;
|
|
12
|
+
|
|
13
|
+
const body = new Body(),
|
|
14
|
+
view =
|
|
15
|
+
|
|
16
|
+
<View/>
|
|
17
|
+
|
|
18
|
+
;
|
|
19
|
+
|
|
20
|
+
renderStyles();
|
|
21
|
+
|
|
22
|
+
body.mount(view);
|
package/src/index.js
ADDED