@zcomponent/core 2.0.0-alpha.2 → 2.0.0-alpha.4
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/lib/animation/layer.js +5 -0
- package/lib/animation/tracks/streamtrack.js +12 -1
- package/lib/behavior.d.ts +7 -1
- package/lib/behavior.js +6 -1
- package/lib/behaviors/ConsoleLog.d.ts +2 -0
- package/lib/behaviors/ConsoleLog.js +2 -0
- package/lib/behaviors/LaunchURL.d.ts +2 -0
- package/lib/behaviors/LaunchURL.js +2 -0
- package/lib/behaviors/LogAnalyticsEvent.d.ts +2 -0
- package/lib/behaviors/LogAnalyticsEvent.js +2 -0
- package/lib/behaviors/PlaySound.d.ts +3 -0
- package/lib/behaviors/PlaySound.js +7 -1
- package/lib/behaviors/ShowTextAlert.d.ts +1 -0
- package/lib/behaviors/ShowTextAlert.js +1 -0
- package/lib/behaviors/ToggleLayerClips.d.ts +1 -0
- package/lib/behaviors/ToggleLayerClips.js +9 -3
- package/lib/component.d.ts +7 -0
- package/lib/component.js +6 -0
- package/lib/components/AnimatedLoader.d.ts +6 -0
- package/lib/components/AnimatedLoader.js +6 -0
- package/lib/components/Audio.d.ts +28 -2
- package/lib/components/Audio.js +55 -8
- package/lib/components/DefaultCookieConsent.d.ts +11 -0
- package/lib/components/DefaultCookieConsent.js +33 -9
- package/lib/components/DefaultLoader.d.ts +3 -0
- package/lib/components/DefaultLoader.js +15 -8
- package/lib/components/Gamepad.d.ts +61 -0
- package/lib/components/Gamepad.js +61 -0
- package/lib/components/LongLoad.d.ts +3 -0
- package/lib/components/LongLoad.js +3 -0
- package/lib/components/SnapshotUI.d.ts +14 -0
- package/lib/components/SnapshotUI.js +27 -9
- package/lib/context.d.ts +11 -1
- package/lib/context.js +9 -1
- package/lib/contexts/analyticscontext.d.ts +3 -0
- package/lib/contexts/analyticscontext.js +14 -2
- package/lib/contexts/audiocontextcontext.d.ts +12 -0
- package/lib/contexts/audiocontextcontext.js +131 -56
- package/lib/contexts/canvascontext.d.ts +25 -0
- package/lib/contexts/canvascontext.js +75 -15
- package/lib/contexts/cookieconsentcontext.d.ts +19 -0
- package/lib/contexts/cookieconsentcontext.js +135 -27
- package/lib/contexts/environmentcontext.d.ts +13 -5
- package/lib/contexts/environmentcontext.js +26 -14
- package/lib/contexts/gamepadcontext.d.ts +17 -0
- package/lib/contexts/gamepadcontext.js +160 -74
- package/lib/contexts/gesturecontext.d.ts +11 -0
- package/lib/contexts/gesturecontext.js +266 -169
- package/lib/contexts/globaltagcontext.d.ts +2 -0
- package/lib/contexts/globaltagcontext.js +69 -10
- package/lib/contexts/loadcontext.d.ts +19 -0
- package/lib/contexts/loadcontext.js +68 -18
- package/lib/contexts/orientationcontext.d.ts +13 -0
- package/lib/contexts/orientationcontext.js +60 -11
- package/lib/contexts/snapshotContext.d.ts +10 -0
- package/lib/contexts/snapshotContext.js +55 -9
- package/lib/contexts/tagcontext.d.ts +14 -0
- package/lib/contexts/tagcontext.js +186 -98
- package/lib/entity.d.ts +5 -1
- package/lib/entity.js +4 -1
- package/lib/zcomponent.d.ts +20 -0
- package/lib/zcomponent.js +81 -12
- package/package.json +84 -84
|
@@ -55,38 +55,46 @@ export declare class GestureContext extends Context<ConstructionProps> {
|
|
|
55
55
|
private initialTouchX;
|
|
56
56
|
/**
|
|
57
57
|
* Observable representing the current rotation value.
|
|
58
|
+
* @zignore
|
|
58
59
|
*/
|
|
59
60
|
rotation: Observable<number, never>;
|
|
60
61
|
/**
|
|
61
62
|
* Observable representing the current scale value.
|
|
63
|
+
* @zignore
|
|
62
64
|
*/
|
|
63
65
|
scale: Observable<number, never>;
|
|
64
66
|
/**
|
|
65
67
|
* Event triggered when rotation occurs.
|
|
68
|
+
* @zignore
|
|
66
69
|
*/
|
|
67
70
|
onRotate: Event<[number]>;
|
|
68
71
|
/**
|
|
69
72
|
* Event triggered when scaling occurs.
|
|
73
|
+
* @zignore
|
|
70
74
|
*/
|
|
71
75
|
onScale: Event<[number]>;
|
|
72
76
|
/**
|
|
73
77
|
* Observable indicating whether gesture interactions are enabled.
|
|
74
78
|
* Defaults to true.
|
|
79
|
+
* @zignore
|
|
75
80
|
*/
|
|
76
81
|
enabled: Observable<boolean, never>;
|
|
77
82
|
/**
|
|
78
83
|
* Minimum scale factor. Defaults to 0.5.
|
|
79
84
|
* @default 0.5
|
|
85
|
+
* @zignore
|
|
80
86
|
*/
|
|
81
87
|
minScale: number;
|
|
82
88
|
/**
|
|
83
89
|
* Maximum scale factor. Defaults to 2.
|
|
84
90
|
* @default 2
|
|
91
|
+
* @zignore
|
|
85
92
|
*/
|
|
86
93
|
maxScale: number;
|
|
87
94
|
/**
|
|
88
95
|
* Sensitivity of rotation. Defaults to 1.
|
|
89
96
|
* @default 1
|
|
97
|
+
* @zignore
|
|
90
98
|
*/
|
|
91
99
|
rotationSensitivity: number;
|
|
92
100
|
/**
|
|
@@ -106,6 +114,9 @@ export declare class GestureContext extends Context<ConstructionProps> {
|
|
|
106
114
|
private getAngleBetweenTouches;
|
|
107
115
|
private attachEventListeners;
|
|
108
116
|
private detachEventListeners;
|
|
117
|
+
/**
|
|
118
|
+
* @zignore
|
|
119
|
+
*/
|
|
109
120
|
dispose(): never;
|
|
110
121
|
}
|
|
111
122
|
export {};
|
|
@@ -1,4 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { Context, Event, isDevelopmentBuild, isEditTime, Observable, useCanvas, zIgnore } from '../index';
|
|
2
36
|
/**
|
|
3
37
|
* Defines the modes for interpreting touch gestures.
|
|
4
38
|
*/
|
|
@@ -13,181 +47,244 @@ Object.freeze(GestureMode);
|
|
|
13
47
|
* @deprecated Use the GestureTransform component instead. This context will be removed in the next major version.
|
|
14
48
|
* @zcontext
|
|
15
49
|
**/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
enabled = new Observable(true);
|
|
67
|
-
/**
|
|
68
|
-
* Minimum scale factor. Defaults to 0.5.
|
|
69
|
-
* @default 0.5
|
|
70
|
-
*/
|
|
71
|
-
minScale = 0.5;
|
|
72
|
-
/**
|
|
73
|
-
* Maximum scale factor. Defaults to 2.
|
|
74
|
-
* @default 2
|
|
75
|
-
*/
|
|
76
|
-
maxScale = 2;
|
|
77
|
-
/**
|
|
78
|
-
* Sensitivity of rotation. Defaults to 1.
|
|
79
|
-
* @default 1
|
|
80
|
-
*/
|
|
81
|
-
rotationSensitivity = 1;
|
|
82
|
-
/**
|
|
83
|
-
* Creates an instance of GestureContext.
|
|
84
|
-
* @param contextManager - The current ContextManager
|
|
85
|
-
* @param constructorProps - The constructor properties.
|
|
86
|
-
*/
|
|
87
|
-
constructor(contextManager, constructorProps) {
|
|
88
|
-
super(contextManager, constructorProps);
|
|
89
|
-
if (isDevelopmentBuild(contextManager) || isEditTime(contextManager)) {
|
|
90
|
-
console.warn('GestureContext is deprecated. Please use the GestureTransform component instead. GestureContext will be removed in the next major version.');
|
|
50
|
+
let GestureContext = (() => {
|
|
51
|
+
let _classSuper = Context;
|
|
52
|
+
let _instanceExtraInitializers = [];
|
|
53
|
+
let _rotation_decorators;
|
|
54
|
+
let _rotation_initializers = [];
|
|
55
|
+
let _rotation_extraInitializers = [];
|
|
56
|
+
let _scale_decorators;
|
|
57
|
+
let _scale_initializers = [];
|
|
58
|
+
let _scale_extraInitializers = [];
|
|
59
|
+
let _onRotate_decorators;
|
|
60
|
+
let _onRotate_initializers = [];
|
|
61
|
+
let _onRotate_extraInitializers = [];
|
|
62
|
+
let _onScale_decorators;
|
|
63
|
+
let _onScale_initializers = [];
|
|
64
|
+
let _onScale_extraInitializers = [];
|
|
65
|
+
let _enabled_decorators;
|
|
66
|
+
let _enabled_initializers = [];
|
|
67
|
+
let _enabled_extraInitializers = [];
|
|
68
|
+
let _minScale_decorators;
|
|
69
|
+
let _minScale_initializers = [];
|
|
70
|
+
let _minScale_extraInitializers = [];
|
|
71
|
+
let _maxScale_decorators;
|
|
72
|
+
let _maxScale_initializers = [];
|
|
73
|
+
let _maxScale_extraInitializers = [];
|
|
74
|
+
let _rotationSensitivity_decorators;
|
|
75
|
+
let _rotationSensitivity_initializers = [];
|
|
76
|
+
let _rotationSensitivity_extraInitializers = [];
|
|
77
|
+
let _dispose_decorators;
|
|
78
|
+
return class GestureContext extends _classSuper {
|
|
79
|
+
static {
|
|
80
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
81
|
+
_rotation_decorators = [zIgnore()];
|
|
82
|
+
_scale_decorators = [zIgnore()];
|
|
83
|
+
_onRotate_decorators = [zIgnore()];
|
|
84
|
+
_onScale_decorators = [zIgnore()];
|
|
85
|
+
_enabled_decorators = [zIgnore()];
|
|
86
|
+
_minScale_decorators = [zIgnore()];
|
|
87
|
+
_maxScale_decorators = [zIgnore()];
|
|
88
|
+
_rotationSensitivity_decorators = [zIgnore()];
|
|
89
|
+
_dispose_decorators = [zIgnore()];
|
|
90
|
+
__esDecorate(this, null, _dispose_decorators, { kind: "method", name: "dispose", static: false, private: false, access: { has: obj => "dispose" in obj, get: obj => obj.dispose }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
91
|
+
__esDecorate(null, null, _rotation_decorators, { kind: "field", name: "rotation", static: false, private: false, access: { has: obj => "rotation" in obj, get: obj => obj.rotation, set: (obj, value) => { obj.rotation = value; } }, metadata: _metadata }, _rotation_initializers, _rotation_extraInitializers);
|
|
92
|
+
__esDecorate(null, null, _scale_decorators, { kind: "field", name: "scale", static: false, private: false, access: { has: obj => "scale" in obj, get: obj => obj.scale, set: (obj, value) => { obj.scale = value; } }, metadata: _metadata }, _scale_initializers, _scale_extraInitializers);
|
|
93
|
+
__esDecorate(null, null, _onRotate_decorators, { kind: "field", name: "onRotate", static: false, private: false, access: { has: obj => "onRotate" in obj, get: obj => obj.onRotate, set: (obj, value) => { obj.onRotate = value; } }, metadata: _metadata }, _onRotate_initializers, _onRotate_extraInitializers);
|
|
94
|
+
__esDecorate(null, null, _onScale_decorators, { kind: "field", name: "onScale", static: false, private: false, access: { has: obj => "onScale" in obj, get: obj => obj.onScale, set: (obj, value) => { obj.onScale = value; } }, metadata: _metadata }, _onScale_initializers, _onScale_extraInitializers);
|
|
95
|
+
__esDecorate(null, null, _enabled_decorators, { kind: "field", name: "enabled", static: false, private: false, access: { has: obj => "enabled" in obj, get: obj => obj.enabled, set: (obj, value) => { obj.enabled = value; } }, metadata: _metadata }, _enabled_initializers, _enabled_extraInitializers);
|
|
96
|
+
__esDecorate(null, null, _minScale_decorators, { kind: "field", name: "minScale", static: false, private: false, access: { has: obj => "minScale" in obj, get: obj => obj.minScale, set: (obj, value) => { obj.minScale = value; } }, metadata: _metadata }, _minScale_initializers, _minScale_extraInitializers);
|
|
97
|
+
__esDecorate(null, null, _maxScale_decorators, { kind: "field", name: "maxScale", static: false, private: false, access: { has: obj => "maxScale" in obj, get: obj => obj.maxScale, set: (obj, value) => { obj.maxScale = value; } }, metadata: _metadata }, _maxScale_initializers, _maxScale_extraInitializers);
|
|
98
|
+
__esDecorate(null, null, _rotationSensitivity_decorators, { kind: "field", name: "rotationSensitivity", static: false, private: false, access: { has: obj => "rotationSensitivity" in obj, get: obj => obj.rotationSensitivity, set: (obj, value) => { obj.rotationSensitivity = value; } }, metadata: _metadata }, _rotationSensitivity_initializers, _rotationSensitivity_extraInitializers);
|
|
99
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
91
100
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
element = __runInitializers(this, _instanceExtraInitializers);
|
|
102
|
+
/**
|
|
103
|
+
* @default true
|
|
104
|
+
*/
|
|
105
|
+
canScale = true;
|
|
106
|
+
/**
|
|
107
|
+
* @default "Scale Rotate"
|
|
108
|
+
*/
|
|
109
|
+
gestureMode = GestureMode.ScaleRotate;
|
|
110
|
+
/**
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
canRotate = true;
|
|
114
|
+
/**
|
|
115
|
+
* @default null
|
|
116
|
+
*/
|
|
117
|
+
initialDistance = null;
|
|
118
|
+
/**
|
|
119
|
+
* @default null
|
|
120
|
+
*/
|
|
121
|
+
initialAngle = null;
|
|
122
|
+
/**
|
|
123
|
+
* @default true
|
|
124
|
+
*/
|
|
125
|
+
oneFingerRotateMode = true;
|
|
126
|
+
/**
|
|
127
|
+
* @default null
|
|
128
|
+
*/
|
|
129
|
+
initialTouchX = null;
|
|
130
|
+
/**
|
|
131
|
+
* Observable representing the current rotation value.
|
|
132
|
+
* @zignore
|
|
133
|
+
*/
|
|
134
|
+
rotation = __runInitializers(this, _rotation_initializers, new Observable(0));
|
|
135
|
+
/**
|
|
136
|
+
* Observable representing the current scale value.
|
|
137
|
+
* @zignore
|
|
138
|
+
*/
|
|
139
|
+
scale = (__runInitializers(this, _rotation_extraInitializers), __runInitializers(this, _scale_initializers, new Observable(0)));
|
|
140
|
+
/**
|
|
141
|
+
* Event triggered when rotation occurs.
|
|
142
|
+
* @zignore
|
|
143
|
+
*/
|
|
144
|
+
onRotate = (__runInitializers(this, _scale_extraInitializers), __runInitializers(this, _onRotate_initializers, new Event()));
|
|
145
|
+
/**
|
|
146
|
+
* Event triggered when scaling occurs.
|
|
147
|
+
* @zignore
|
|
148
|
+
*/
|
|
149
|
+
onScale = (__runInitializers(this, _onRotate_extraInitializers), __runInitializers(this, _onScale_initializers, new Event()));
|
|
150
|
+
/**
|
|
151
|
+
* Observable indicating whether gesture interactions are enabled.
|
|
152
|
+
* Defaults to true.
|
|
153
|
+
* @zignore
|
|
154
|
+
*/
|
|
155
|
+
enabled = (__runInitializers(this, _onScale_extraInitializers), __runInitializers(this, _enabled_initializers, new Observable(true)));
|
|
156
|
+
/**
|
|
157
|
+
* Minimum scale factor. Defaults to 0.5.
|
|
158
|
+
* @default 0.5
|
|
159
|
+
* @zignore
|
|
160
|
+
*/
|
|
161
|
+
minScale = (__runInitializers(this, _enabled_extraInitializers), __runInitializers(this, _minScale_initializers, 0.5));
|
|
162
|
+
/**
|
|
163
|
+
* Maximum scale factor. Defaults to 2.
|
|
164
|
+
* @default 2
|
|
165
|
+
* @zignore
|
|
166
|
+
*/
|
|
167
|
+
maxScale = (__runInitializers(this, _minScale_extraInitializers), __runInitializers(this, _maxScale_initializers, 2));
|
|
168
|
+
/**
|
|
169
|
+
* Sensitivity of rotation. Defaults to 1.
|
|
170
|
+
* @default 1
|
|
171
|
+
* @zignore
|
|
172
|
+
*/
|
|
173
|
+
rotationSensitivity = (__runInitializers(this, _maxScale_extraInitializers), __runInitializers(this, _rotationSensitivity_initializers, 1));
|
|
174
|
+
/**
|
|
175
|
+
* Creates an instance of GestureContext.
|
|
176
|
+
* @param contextManager - The current ContextManager
|
|
177
|
+
* @param constructorProps - The constructor properties.
|
|
178
|
+
*/
|
|
179
|
+
constructor(contextManager, constructorProps) {
|
|
180
|
+
super(contextManager, constructorProps);
|
|
181
|
+
if (isDevelopmentBuild(contextManager) || isEditTime(contextManager)) {
|
|
182
|
+
console.warn('GestureContext is deprecated. Please use the GestureTransform component instead. GestureContext will be removed in the next major version.');
|
|
96
183
|
}
|
|
97
|
-
|
|
98
|
-
|
|
184
|
+
this.element = constructorProps.element ?? useCanvas(contextManager);
|
|
185
|
+
this.enabled.addListener(enabled => {
|
|
186
|
+
if (enabled) {
|
|
187
|
+
this.attachEventListeners();
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
this.detachEventListeners();
|
|
191
|
+
}
|
|
192
|
+
}, undefined, true);
|
|
193
|
+
}
|
|
194
|
+
onTouchStart = (__runInitializers(this, _rotationSensitivity_extraInitializers), (event) => {
|
|
195
|
+
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
196
|
+
this.initialTouchX = event.touches[0].pageX;
|
|
197
|
+
}
|
|
198
|
+
else if (event.touches.length === 2) {
|
|
199
|
+
this.initialDistance = this.getDistanceBetweenTouches(event.touches);
|
|
200
|
+
this.initialAngle = this.getAngleBetweenTouches(event.touches);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
onTouchMove = (event) => {
|
|
204
|
+
switch (this.gestureMode) {
|
|
205
|
+
case GestureMode.ScaleOnly:
|
|
206
|
+
if (event.touches.length === 2) {
|
|
207
|
+
this.handleScale(event);
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case GestureMode.RotateOnly:
|
|
211
|
+
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
212
|
+
this.handleOneFingerRotate(event);
|
|
213
|
+
}
|
|
214
|
+
else if (event.touches.length === 2) {
|
|
215
|
+
this.handleRotate(event);
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
case GestureMode.ScaleRotate:
|
|
219
|
+
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
220
|
+
this.handleOneFingerRotate(event);
|
|
221
|
+
}
|
|
222
|
+
else if (event.touches.length === 2) {
|
|
223
|
+
this.handleTwoFingerGestures(event);
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
handleOneFingerRotate(event) {
|
|
229
|
+
if (this.initialTouchX !== null) {
|
|
230
|
+
const currentTouchX = event.touches[0].pageX;
|
|
231
|
+
const rotateAmount = (currentTouchX - this.initialTouchX) * this.rotationSensitivity;
|
|
232
|
+
this.onRotate.emit(rotateAmount);
|
|
233
|
+
this.rotation.value = rotateAmount;
|
|
99
234
|
}
|
|
100
|
-
}, undefined, true);
|
|
101
|
-
}
|
|
102
|
-
onTouchStart = (event) => {
|
|
103
|
-
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
104
|
-
this.initialTouchX = event.touches[0].pageX;
|
|
105
235
|
}
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
this.
|
|
236
|
+
handleTwoFingerGestures(event) {
|
|
237
|
+
this.handleScale(event);
|
|
238
|
+
this.handleRotate(event);
|
|
109
239
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case GestureMode.RotateOnly:
|
|
119
|
-
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
120
|
-
this.handleOneFingerRotate(event);
|
|
121
|
-
}
|
|
122
|
-
else if (event.touches.length === 2) {
|
|
123
|
-
this.handleRotate(event);
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
case GestureMode.ScaleRotate:
|
|
127
|
-
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
128
|
-
this.handleOneFingerRotate(event);
|
|
129
|
-
}
|
|
130
|
-
else if (event.touches.length === 2) {
|
|
131
|
-
this.handleTwoFingerGestures(event);
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
240
|
+
handleScale(event) {
|
|
241
|
+
if (this.canScale && this.initialDistance !== null) {
|
|
242
|
+
const currentDistance = this.getDistanceBetweenTouches(event.touches);
|
|
243
|
+
let scaleAmount = currentDistance / this.initialDistance;
|
|
244
|
+
scaleAmount = Math.max(this.minScale, Math.min(scaleAmount, this.maxScale));
|
|
245
|
+
this.onScale.emit(scaleAmount);
|
|
246
|
+
this.scale.value = scaleAmount;
|
|
247
|
+
}
|
|
134
248
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
249
|
+
handleRotate(event) {
|
|
250
|
+
if (this.canRotate && this.initialAngle !== null) {
|
|
251
|
+
const currentAngle = this.getAngleBetweenTouches(event.touches);
|
|
252
|
+
const rotateAmount = currentAngle - this.initialAngle;
|
|
253
|
+
this.onRotate.emit(-rotateAmount);
|
|
254
|
+
this.rotation.value = -rotateAmount;
|
|
255
|
+
}
|
|
142
256
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let scaleAmount = currentDistance / this.initialDistance;
|
|
152
|
-
scaleAmount = Math.max(this.minScale, Math.min(scaleAmount, this.maxScale));
|
|
153
|
-
this.onScale.emit(scaleAmount);
|
|
154
|
-
this.scale.value = scaleAmount;
|
|
257
|
+
onTouchEnd = (event) => {
|
|
258
|
+
this.initialDistance = null;
|
|
259
|
+
this.initialAngle = null;
|
|
260
|
+
};
|
|
261
|
+
getDistanceBetweenTouches(touches) {
|
|
262
|
+
const dx = touches[0].pageX - touches[1].pageX;
|
|
263
|
+
const dy = touches[0].pageY - touches[1].pageY;
|
|
264
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
155
265
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.
|
|
266
|
+
getAngleBetweenTouches(touches) {
|
|
267
|
+
const dx = touches[1].pageX - touches[0].pageX;
|
|
268
|
+
const dy = touches[1].pageY - touches[0].pageY;
|
|
269
|
+
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
270
|
+
}
|
|
271
|
+
attachEventListeners() {
|
|
272
|
+
this.element.addEventListener('touchstart', this.onTouchStart, { passive: true });
|
|
273
|
+
this.element.addEventListener('touchmove', this.onTouchMove, { passive: true });
|
|
274
|
+
this.element.addEventListener('touchend', this.onTouchEnd);
|
|
275
|
+
}
|
|
276
|
+
detachEventListeners() {
|
|
277
|
+
this.element.removeEventListener('touchstart', this.onTouchStart);
|
|
278
|
+
this.element.removeEventListener('touchmove', this.onTouchMove);
|
|
279
|
+
this.element.removeEventListener('touchend', this.onTouchEnd);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @zignore
|
|
283
|
+
*/
|
|
284
|
+
dispose() {
|
|
285
|
+
this.detachEventListeners();
|
|
286
|
+
return super.dispose();
|
|
163
287
|
}
|
|
164
|
-
}
|
|
165
|
-
onTouchEnd = (event) => {
|
|
166
|
-
this.initialDistance = null;
|
|
167
|
-
this.initialAngle = null;
|
|
168
288
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const dy = touches[0].pageY - touches[1].pageY;
|
|
172
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
173
|
-
}
|
|
174
|
-
getAngleBetweenTouches(touches) {
|
|
175
|
-
const dx = touches[1].pageX - touches[0].pageX;
|
|
176
|
-
const dy = touches[1].pageY - touches[0].pageY;
|
|
177
|
-
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
178
|
-
}
|
|
179
|
-
attachEventListeners() {
|
|
180
|
-
this.element.addEventListener('touchstart', this.onTouchStart, { passive: true });
|
|
181
|
-
this.element.addEventListener('touchmove', this.onTouchMove, { passive: true });
|
|
182
|
-
this.element.addEventListener('touchend', this.onTouchEnd);
|
|
183
|
-
}
|
|
184
|
-
detachEventListeners() {
|
|
185
|
-
this.element.removeEventListener('touchstart', this.onTouchStart);
|
|
186
|
-
this.element.removeEventListener('touchmove', this.onTouchMove);
|
|
187
|
-
this.element.removeEventListener('touchend', this.onTouchEnd);
|
|
188
|
-
}
|
|
189
|
-
dispose() {
|
|
190
|
-
this.detachEventListeners();
|
|
191
|
-
return super.dispose();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
289
|
+
})();
|
|
290
|
+
export { GestureContext };
|
|
@@ -8,10 +8,12 @@ import { Event } from '../event';
|
|
|
8
8
|
export declare class GlobalTagContext extends Context {
|
|
9
9
|
/**
|
|
10
10
|
* A map storing the relationship between global tags and sets of components.
|
|
11
|
+
* @zignore
|
|
11
12
|
*/
|
|
12
13
|
readonly componentsByGlobalTag: Map<string, Set<Component<any, import("..").ConstructorProps>>>;
|
|
13
14
|
/**
|
|
14
15
|
* An event that's emitted when the set of components that constitute a tag changes.
|
|
16
|
+
* @zignore
|
|
15
17
|
*/
|
|
16
18
|
readonly onTagChange: Event<[string]>;
|
|
17
19
|
}
|
|
@@ -1,16 +1,75 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
1
35
|
import { Context } from '../context';
|
|
36
|
+
import { zIgnore } from '../decorators';
|
|
2
37
|
import { Event } from '../event';
|
|
3
38
|
/**
|
|
4
39
|
* Manages the association between global tags and components.
|
|
5
40
|
* @zcontext
|
|
6
41
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
42
|
+
let GlobalTagContext = (() => {
|
|
43
|
+
let _classSuper = Context;
|
|
44
|
+
let _componentsByGlobalTag_decorators;
|
|
45
|
+
let _componentsByGlobalTag_initializers = [];
|
|
46
|
+
let _componentsByGlobalTag_extraInitializers = [];
|
|
47
|
+
let _onTagChange_decorators;
|
|
48
|
+
let _onTagChange_initializers = [];
|
|
49
|
+
let _onTagChange_extraInitializers = [];
|
|
50
|
+
return class GlobalTagContext extends _classSuper {
|
|
51
|
+
static {
|
|
52
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
53
|
+
_componentsByGlobalTag_decorators = [zIgnore()];
|
|
54
|
+
_onTagChange_decorators = [zIgnore()];
|
|
55
|
+
__esDecorate(null, null, _componentsByGlobalTag_decorators, { kind: "field", name: "componentsByGlobalTag", static: false, private: false, access: { has: obj => "componentsByGlobalTag" in obj, get: obj => obj.componentsByGlobalTag, set: (obj, value) => { obj.componentsByGlobalTag = value; } }, metadata: _metadata }, _componentsByGlobalTag_initializers, _componentsByGlobalTag_extraInitializers);
|
|
56
|
+
__esDecorate(null, null, _onTagChange_decorators, { kind: "field", name: "onTagChange", static: false, private: false, access: { has: obj => "onTagChange" in obj, get: obj => obj.onTagChange, set: (obj, value) => { obj.onTagChange = value; } }, metadata: _metadata }, _onTagChange_initializers, _onTagChange_extraInitializers);
|
|
57
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A map storing the relationship between global tags and sets of components.
|
|
61
|
+
* @zignore
|
|
62
|
+
*/
|
|
63
|
+
componentsByGlobalTag = __runInitializers(this, _componentsByGlobalTag_initializers, new Map());
|
|
64
|
+
/**
|
|
65
|
+
* An event that's emitted when the set of components that constitute a tag changes.
|
|
66
|
+
* @zignore
|
|
67
|
+
*/
|
|
68
|
+
onTagChange = (__runInitializers(this, _componentsByGlobalTag_extraInitializers), __runInitializers(this, _onTagChange_initializers, new Event()));
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
__runInitializers(this, _onTagChange_extraInitializers);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
})();
|
|
75
|
+
export { GlobalTagContext };
|