targetj 1.0.256 → 1.0.258
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/Export.js +46 -65
- package/README.md +52 -22
- package/build/AnimationManager.js +349 -155
- package/build/AnimationUtil.js +59 -6
- package/build/App.js +14 -3
- package/build/BaseModel.js +61 -50
- package/build/EventListener.js +24 -6
- package/build/LoadingManager.js +255 -52
- package/build/PageManager.js +170 -242
- package/build/RunScheduler.js +42 -26
- package/build/SearchUtil.js +10 -0
- package/build/StateManager.js +293 -0
- package/build/StateUtil.js +600 -0
- package/build/TModel.js +10 -2
- package/build/TModelUtil.js +366 -75
- package/build/TUtil.js +7 -0
- package/build/TargetExecutor.js +52 -31
- package/build/TargetUtil.js +54 -22
- package/build/index.js +2 -1
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +22 -6
- package/types/index.d.ts +303 -0
package/build/AnimationUtil.js
CHANGED
|
@@ -97,6 +97,7 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
97
97
|
var batch = {
|
|
98
98
|
frames: frames,
|
|
99
99
|
keyMap: keyMap,
|
|
100
|
+
snap: true,
|
|
100
101
|
totalDuration: 1
|
|
101
102
|
};
|
|
102
103
|
getAnimationManager().animate(tmodel, batch, AnimationUtil.getAnimationHooks());
|
|
@@ -320,12 +321,36 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
320
321
|
step = result.step,
|
|
321
322
|
steps = result.steps,
|
|
322
323
|
cycle = result.cycle,
|
|
323
|
-
valuePointer = result.valuePointer
|
|
324
|
+
valuePointer = result.valuePointer,
|
|
325
|
+
from = result.from,
|
|
326
|
+
to = result.to,
|
|
327
|
+
interval = result.interval,
|
|
328
|
+
easing = result.easing;
|
|
324
329
|
getAnimationManager().setAt(tmodel, cleanKey, value);
|
|
325
330
|
tmodel.val(originalKey, value);
|
|
326
331
|
var targetValue = tmodel.targetValues[originalKey];
|
|
327
332
|
if (targetValue) {
|
|
328
|
-
|
|
333
|
+
var _targetValue$valueLis;
|
|
334
|
+
if ((_targetValue$valueLis = targetValue.valueList) !== null && _targetValue$valueLis !== void 0 && _targetValue$valueLis.length) {
|
|
335
|
+
AnimationUtil.syncListTargetSegment(targetValue, result);
|
|
336
|
+
} else {
|
|
337
|
+
if (TUtil.isDefined(from)) {
|
|
338
|
+
targetValue.initialValue = from;
|
|
339
|
+
}
|
|
340
|
+
if (TUtil.isDefined(to)) {
|
|
341
|
+
targetValue.value = to;
|
|
342
|
+
}
|
|
343
|
+
if (TUtil.isDefined(steps)) {
|
|
344
|
+
targetValue.steps = steps;
|
|
345
|
+
}
|
|
346
|
+
if (TUtil.isDefined(interval)) {
|
|
347
|
+
targetValue.interval = interval;
|
|
348
|
+
}
|
|
349
|
+
if (TUtil.isDefined(easing)) {
|
|
350
|
+
targetValue.easing = easing;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (TUtil.isDefined(step)) {
|
|
329
354
|
targetValue.step = step;
|
|
330
355
|
}
|
|
331
356
|
if (TUtil.isDefined(valuePointer)) {
|
|
@@ -334,6 +359,7 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
334
359
|
if (TUtil.isDefined(cycle)) {
|
|
335
360
|
targetValue.cycle = cycle;
|
|
336
361
|
}
|
|
362
|
+
targetValue.lastUpdate = TUtil.now();
|
|
337
363
|
tmodel.setActual(originalKey, value);
|
|
338
364
|
var fireKey = "".concat(cycle, ":").concat(valuePointer, ":").concat(step);
|
|
339
365
|
if (record.needsFireOnStep && step > 0 && steps > 0 && record.lastFireOnStepKey !== fireKey) {
|
|
@@ -403,6 +429,8 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
403
429
|
steps: right.segmentSteps,
|
|
404
430
|
from: from,
|
|
405
431
|
to: to,
|
|
432
|
+
interval: right.interval,
|
|
433
|
+
easing: right.easing,
|
|
406
434
|
valuePointer: (_ref = (_right$valuePointer = right.valuePointer) !== null && _right$valuePointer !== void 0 ? _right$valuePointer : left.valuePointer) !== null && _ref !== void 0 ? _ref : 0,
|
|
407
435
|
cycle: (_ref2 = (_right$cycle = right.cycle) !== null && _right$cycle !== void 0 ? _right$cycle : left.cycle) !== null && _ref2 !== void 0 ? _ref2 : 0,
|
|
408
436
|
status: right.done ? "finished" : "playing"
|
|
@@ -417,10 +445,12 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
417
445
|
value: value,
|
|
418
446
|
step: step,
|
|
419
447
|
steps: segmentSteps,
|
|
420
|
-
valuePointer: (_ref3 = (_right$valuePointer2 = right.valuePointer) !== null && _right$valuePointer2 !== void 0 ? _right$valuePointer2 : left.valuePointer) !== null && _ref3 !== void 0 ? _ref3 : 0,
|
|
421
|
-
cycle: (_ref4 = (_right$cycle2 = right.cycle) !== null && _right$cycle2 !== void 0 ? _right$cycle2 : left.cycle) !== null && _ref4 !== void 0 ? _ref4 : 0,
|
|
422
448
|
from: from,
|
|
423
449
|
to: to,
|
|
450
|
+
interval: right.interval,
|
|
451
|
+
easing: right.easing,
|
|
452
|
+
valuePointer: (_ref3 = (_right$valuePointer2 = right.valuePointer) !== null && _right$valuePointer2 !== void 0 ? _right$valuePointer2 : left.valuePointer) !== null && _ref3 !== void 0 ? _ref3 : 0,
|
|
453
|
+
cycle: (_ref4 = (_right$cycle2 = right.cycle) !== null && _right$cycle2 !== void 0 ? _right$cycle2 : left.cycle) !== null && _ref4 !== void 0 ? _ref4 : 0,
|
|
424
454
|
status: right.done ? "finished" : "playing"
|
|
425
455
|
};
|
|
426
456
|
}
|
|
@@ -577,6 +607,29 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
577
607
|
})))) : 0;
|
|
578
608
|
return removed;
|
|
579
609
|
}
|
|
610
|
+
}, {
|
|
611
|
+
key: "syncListTargetSegment",
|
|
612
|
+
value: function syncListTargetSegment(targetValue, result) {
|
|
613
|
+
var _targetValue$valueLis2, _ref5, _result$valuePointer, _targetValue$stepList, _targetValue$interval, _targetValue$easingLi;
|
|
614
|
+
if (!(targetValue !== null && targetValue !== void 0 && (_targetValue$valueLis2 = targetValue.valueList) !== null && _targetValue$valueLis2 !== void 0 && _targetValue$valueLis2.length)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
var maxPointer = targetValue.valueList.length - 1;
|
|
618
|
+
var pointer = TUtil.limit((_ref5 = (_result$valuePointer = result.valuePointer) !== null && _result$valuePointer !== void 0 ? _result$valuePointer : targetValue.valuePointer) !== null && _ref5 !== void 0 ? _ref5 : 1, 1, maxPointer);
|
|
619
|
+
var segmentIndex = pointer - 1;
|
|
620
|
+
targetValue.valuePointer = pointer;
|
|
621
|
+
targetValue.initialValue = targetValue.valueList[segmentIndex];
|
|
622
|
+
targetValue.value = targetValue.valueList[pointer];
|
|
623
|
+
if ((_targetValue$stepList = targetValue.stepList) !== null && _targetValue$stepList !== void 0 && _targetValue$stepList.length) {
|
|
624
|
+
targetValue.steps = targetValue.stepList[segmentIndex % targetValue.stepList.length];
|
|
625
|
+
}
|
|
626
|
+
if ((_targetValue$interval = targetValue.intervalList) !== null && _targetValue$interval !== void 0 && _targetValue$interval.length) {
|
|
627
|
+
targetValue.interval = targetValue.intervalList[segmentIndex % targetValue.intervalList.length];
|
|
628
|
+
}
|
|
629
|
+
if ((_targetValue$easingLi = targetValue.easingList) !== null && _targetValue$easingLi !== void 0 && _targetValue$easingLi.length) {
|
|
630
|
+
targetValue.easing = targetValue.easingList[segmentIndex % targetValue.easingList.length];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
580
633
|
}, {
|
|
581
634
|
key: "handleWebAnimationAPI",
|
|
582
635
|
value: function handleWebAnimationAPI(tmodel, cleanKey, key, targetValue, from, to, valuePointer, step, steps, interval, timeShift) {
|
|
@@ -631,7 +684,7 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
631
684
|
var cycle = (_targetValue$cycle = targetValue.cycle) !== null && _targetValue$cycle !== void 0 ? _targetValue$cycle : 0;
|
|
632
685
|
var pointer = valuePointer;
|
|
633
686
|
if (!skipStartFrame) {
|
|
634
|
-
var
|
|
687
|
+
var _ref6, _targetValue$cycle2;
|
|
635
688
|
var frame0 = getFrameAtTime(0);
|
|
636
689
|
setFrameValue(frame0, from);
|
|
637
690
|
frame0.keyMeta.set(cleanKey, {
|
|
@@ -639,7 +692,7 @@ var AnimationUtil = /*#__PURE__*/function () {
|
|
|
639
692
|
segmentSteps: steps || targetValue.steps || 0,
|
|
640
693
|
interval: interval || targetValue.interval || 8,
|
|
641
694
|
stepOffset: step || 0,
|
|
642
|
-
valuePointer: (
|
|
695
|
+
valuePointer: (_ref6 = valuePointer !== null && valuePointer !== void 0 ? valuePointer : targetValue.valuePointer) !== null && _ref6 !== void 0 ? _ref6 : 1,
|
|
643
696
|
cycle: (_targetValue$cycle2 = targetValue.cycle) !== null && _targetValue$cycle2 !== void 0 ? _targetValue$cycle2 : 0
|
|
644
697
|
});
|
|
645
698
|
}
|
package/build/App.js
CHANGED
|
@@ -15,6 +15,7 @@ import { EventListener } from "./EventListener.js";
|
|
|
15
15
|
import { LoadingManager } from "./LoadingManager.js";
|
|
16
16
|
import { LocationManager } from "./LocationManager.js";
|
|
17
17
|
import { PageManager } from "./PageManager.js";
|
|
18
|
+
import { StateManager } from "./StateManager.js";
|
|
18
19
|
import { TModelManager } from "./TModelManager.js";
|
|
19
20
|
import { RunScheduler } from "./RunScheduler.js";
|
|
20
21
|
import { TargetManager } from "./TargetManager.js";
|
|
@@ -23,6 +24,7 @@ import { AnimationManager } from "./AnimationManager.js";
|
|
|
23
24
|
import { TUtil } from "./TUtil.js";
|
|
24
25
|
import { DomInit } from "./DomInit.js";
|
|
25
26
|
import { SearchUtil } from "./SearchUtil.js";
|
|
27
|
+
import { TModelUtil } from "./TModelUtil.js";
|
|
26
28
|
var tApp;
|
|
27
29
|
var queuedAppCalls = [];
|
|
28
30
|
var AppFn = function AppFn() {
|
|
@@ -35,6 +37,7 @@ var AppFn = function AppFn() {
|
|
|
35
37
|
my.$window = new $Dom(window);
|
|
36
38
|
my.loader = new LoadingManager();
|
|
37
39
|
my.pager = new PageManager();
|
|
40
|
+
my.stateManager = new StateManager();
|
|
38
41
|
my.events = new EventListener();
|
|
39
42
|
my.locationManager = new LocationManager();
|
|
40
43
|
my.targetManager = new TargetManager();
|
|
@@ -71,9 +74,9 @@ var AppFn = function AppFn() {
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
});
|
|
74
|
-
tmodel.$dom =
|
|
77
|
+
tmodel.$dom = TModelUtil.getRootDom();
|
|
75
78
|
if (tmodel.$dom.getTagName() !== 'body') {
|
|
76
|
-
tmodel.$dom.attr('data-
|
|
79
|
+
tmodel.$dom.attr('data-tj-no-slot', 'true');
|
|
77
80
|
}
|
|
78
81
|
tmodel.val('screenWidth', $Dom.getScreenWidth());
|
|
79
82
|
tmodel.val('screenHeight', $Dom.getScreenHeight());
|
|
@@ -330,6 +333,14 @@ var getResizeLastUpdate = function getResizeLastUpdate() {
|
|
|
330
333
|
var _tApp17;
|
|
331
334
|
return (_tApp17 = tApp) === null || _tApp17 === void 0 ? void 0 : _tApp17.resizeLastUpdate;
|
|
332
335
|
};
|
|
336
|
+
var state = function state() {
|
|
337
|
+
var _tApp18;
|
|
338
|
+
var manager = (_tApp18 = tApp) === null || _tApp18 === void 0 ? void 0 : _tApp18.stateManager;
|
|
339
|
+
if (!manager) {
|
|
340
|
+
throw new Error("TargetJS state manager is not initialized.");
|
|
341
|
+
}
|
|
342
|
+
return manager;
|
|
343
|
+
};
|
|
333
344
|
var getTModelById = function getTModelById(id) {
|
|
334
345
|
return App.tmodelIdMap[id];
|
|
335
346
|
};
|
|
@@ -354,4 +365,4 @@ if (typeof document !== "undefined") {
|
|
|
354
365
|
runApp();
|
|
355
366
|
}
|
|
356
367
|
}
|
|
357
|
-
export { tApp, App, tRoot, isRunning, getEvents, getPager, getLoader, fetch, fetchImage, getManager, getTargetManager, getAnimationManager, getRunScheduler, getLocationManager, getScreenWidth, getScreenHeight, getVisibles, getResizeLastUpdate, getTModelById, getDomTModelById };
|
|
368
|
+
export { tApp, App, tRoot, isRunning, getEvents, getPager, state, getLoader, fetch, fetchImage, getManager, getTargetManager, getAnimationManager, getRunScheduler, getLocationManager, getScreenWidth, getScreenHeight, getVisibles, getResizeLastUpdate, getTModelById, getDomTModelById };
|
package/build/BaseModel.js
CHANGED
|
@@ -30,11 +30,15 @@ import { $Dom } from "./$Dom.js";
|
|
|
30
30
|
var BaseModel = /*#__PURE__*/function () {
|
|
31
31
|
function BaseModel(type, targets, oid) {
|
|
32
32
|
var _targets;
|
|
33
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
33
34
|
_classCallCheck(this, BaseModel);
|
|
34
35
|
if (_typeof(type) === 'object' && typeof targets === 'undefined') {
|
|
35
36
|
targets = type;
|
|
36
37
|
type = "";
|
|
37
38
|
}
|
|
39
|
+
this.restoringRuntime = options.restoringRuntime === true;
|
|
40
|
+
this.restoredUsesExistingDom = options.usesExistingDom === true;
|
|
41
|
+
this.targetDefinitions = TUtil.cloneTargetDefinition(targets);
|
|
38
42
|
this.targets = Object.assign({}, targets);
|
|
39
43
|
oid = oid || this.targets.id;
|
|
40
44
|
if (!TUtil.isDefined(oid)) {
|
|
@@ -211,7 +215,7 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
211
215
|
});
|
|
212
216
|
this.functionTargetNames = [];
|
|
213
217
|
this.allTargetMap = {};
|
|
214
|
-
if (TUtil.isDefined(this.originalId) && getDomTModelById(this.originalId)) {
|
|
218
|
+
if (!this.restoringRuntime && TUtil.isDefined(this.originalId) && getDomTModelById(this.originalId)) {
|
|
215
219
|
TUtil.mergeTargets(getDomTModelById(this.originalId), this);
|
|
216
220
|
this.toDiscard = true;
|
|
217
221
|
return;
|
|
@@ -225,7 +229,8 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
225
229
|
}).map(function (key) {
|
|
226
230
|
return key.startsWith('_') ? key.slice(1) : key;
|
|
227
231
|
});
|
|
228
|
-
var
|
|
232
|
+
var hasDomTarget = this.originalTargetNames.includes('$dom');
|
|
233
|
+
var domExists = this.restoringRuntime ? this.restoredUsesExistingDom || hasDomTarget : Boolean($Dom.query("#".concat(this.oid)) || hasDomTarget);
|
|
229
234
|
if (!domExists && !this.excludeDefaultStyling()) {
|
|
230
235
|
Object.entries(TargetData.defaultTargetStyles).forEach(function (_ref) {
|
|
231
236
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -235,25 +240,25 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
235
240
|
_this.targets[key] = value;
|
|
236
241
|
}
|
|
237
242
|
});
|
|
238
|
-
if (this.targets
|
|
239
|
-
this.targets
|
|
243
|
+
if (this.targets.canHaveDom !== false && !TUtil.isDefined(this.targets.domHolder)) {
|
|
244
|
+
this.targets.domHolder = true;
|
|
240
245
|
}
|
|
241
246
|
} else if (domExists) {
|
|
242
|
-
this.targets
|
|
243
|
-
if (!TUtil.isDefined(this.targets
|
|
244
|
-
this.targets
|
|
245
|
-
this.targets
|
|
246
|
-
if (!TUtil.isDefined(this.targets
|
|
247
|
-
this.targets
|
|
247
|
+
this.targets.domIsland = true;
|
|
248
|
+
if (!TUtil.isDefined(this.targets.reuseDomDefinition)) {
|
|
249
|
+
this.targets.reuseDomDefinition = true;
|
|
250
|
+
this.targets.domHolder = true;
|
|
251
|
+
if (!TUtil.isDefined(this.targets.excludeXYCalc)) {
|
|
252
|
+
this.targets.excludeXYCalc = true;
|
|
248
253
|
}
|
|
249
|
-
if (!TUtil.isDefined(this.targets
|
|
250
|
-
this.targets
|
|
254
|
+
if (!TUtil.isDefined(this.targets.x)) {
|
|
255
|
+
this.targets.excludeX = true;
|
|
251
256
|
}
|
|
252
|
-
if (!TUtil.isDefined(this.targets
|
|
253
|
-
this.targets
|
|
257
|
+
if (!TUtil.isDefined(this.targets.y)) {
|
|
258
|
+
this.targets.excludeY = true;
|
|
254
259
|
}
|
|
255
|
-
if (!TUtil.isDefined(this.targets
|
|
256
|
-
this.targets
|
|
260
|
+
if (!TUtil.isDefined(this.targets.position)) {
|
|
261
|
+
this.targets.position = 'relative';
|
|
257
262
|
}
|
|
258
263
|
}
|
|
259
264
|
}
|
|
@@ -434,6 +439,7 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
434
439
|
}, {
|
|
435
440
|
key: "removeTarget",
|
|
436
441
|
value: function removeTarget(key) {
|
|
442
|
+
delete this.targetDefinitions[key];
|
|
437
443
|
delete this.targets[key];
|
|
438
444
|
this.removeFromActiveTargets(key);
|
|
439
445
|
this.removeFromUpdatingTargets(key);
|
|
@@ -449,6 +455,11 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
449
455
|
value: function addTargets(targets) {
|
|
450
456
|
var _this2 = this,
|
|
451
457
|
_getRunScheduler;
|
|
458
|
+
var definitions = TUtil.cloneTargetDefinition(targets);
|
|
459
|
+
for (var _i = 0, _Object$keys = Object.keys(definitions); _i < _Object$keys.length; _i++) {
|
|
460
|
+
var key = _Object$keys[_i];
|
|
461
|
+
this.targetDefinitions[key] = definitions[key];
|
|
462
|
+
}
|
|
452
463
|
Object.keys(targets).forEach(function (key) {
|
|
453
464
|
_this2.targets[key] = targets[key];
|
|
454
465
|
_this2.removeFromUpdatingTargets(key);
|
|
@@ -461,7 +472,7 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
461
472
|
if (this.hasDom()) {
|
|
462
473
|
getEvents().attachEvents([this]);
|
|
463
474
|
}
|
|
464
|
-
(_getRunScheduler = getRunScheduler()) === null || _getRunScheduler === void 0 || _getRunScheduler.schedule(1,
|
|
475
|
+
(_getRunScheduler = getRunScheduler()) === null || _getRunScheduler === void 0 || _getRunScheduler.schedule(1, "addTargets-".concat(this.oid));
|
|
465
476
|
}
|
|
466
477
|
}, {
|
|
467
478
|
key: "getTargetStepPercent",
|
|
@@ -963,25 +974,15 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
963
974
|
}, {
|
|
964
975
|
key: "cancelAnimation",
|
|
965
976
|
value: function cancelAnimation() {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
if (this.targetValues[key]) {
|
|
976
|
-
this.addTargetToStatusList(key);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
} catch (err) {
|
|
980
|
-
_iterator2.e(err);
|
|
981
|
-
} finally {
|
|
982
|
-
_iterator2.f();
|
|
983
|
-
}
|
|
984
|
-
getAnimationManager().deleteAnimation(this);
|
|
977
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
978
|
+
var _options$mode = options.mode,
|
|
979
|
+
mode = _options$mode === void 0 ? "hold" : _options$mode,
|
|
980
|
+
_options$commitStyle = options.commitStyle,
|
|
981
|
+
commitStyle = _options$commitStyle === void 0 ? true : _options$commitStyle;
|
|
982
|
+
return getAnimationManager().cancelTModelAnimation(this, {
|
|
983
|
+
mode: mode,
|
|
984
|
+
commitStyle: commitStyle
|
|
985
|
+
});
|
|
985
986
|
}
|
|
986
987
|
}, {
|
|
987
988
|
key: "hasTargetUpdates",
|
|
@@ -1046,39 +1047,49 @@ var BaseModel = /*#__PURE__*/function () {
|
|
|
1046
1047
|
value: function hasUpdatingImperativeTargets(originalTargetName) {
|
|
1047
1048
|
var _this$updatingTargetL;
|
|
1048
1049
|
var updatingList = [].concat(_toConsumableArray((_this$updatingTargetL = this.updatingTargetList) !== null && _this$updatingTargetL !== void 0 ? _this$updatingTargetL : []), _toConsumableArray(this.hasAnimatingTargets() ? _toConsumableArray(this.animatingMap.keys()) : []));
|
|
1049
|
-
var
|
|
1050
|
-
|
|
1050
|
+
var _iterator2 = _createForOfIteratorHelper(updatingList),
|
|
1051
|
+
_step2;
|
|
1051
1052
|
try {
|
|
1052
|
-
for (
|
|
1053
|
-
var
|
|
1054
|
-
|
|
1053
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1054
|
+
var _this$targetValues$ta;
|
|
1055
|
+
var target = _step2.value;
|
|
1056
|
+
if (!this.isTargetImperative(target)) {
|
|
1057
|
+
continue;
|
|
1058
|
+
}
|
|
1059
|
+
if (((_this$targetValues$ta = this.targetValues[target]) === null || _this$targetValues$ta === void 0 ? void 0 : _this$targetValues$ta.originalTargetName) === originalTargetName) {
|
|
1055
1060
|
return true;
|
|
1056
1061
|
}
|
|
1057
1062
|
}
|
|
1058
1063
|
} catch (err) {
|
|
1059
|
-
|
|
1064
|
+
_iterator2.e(err);
|
|
1060
1065
|
} finally {
|
|
1061
|
-
|
|
1066
|
+
_iterator2.f();
|
|
1062
1067
|
}
|
|
1063
1068
|
return false;
|
|
1064
1069
|
}
|
|
1065
1070
|
}, {
|
|
1066
1071
|
key: "getUpdatingImperativeTargets",
|
|
1067
1072
|
value: function getUpdatingImperativeTargets(originalTargetName) {
|
|
1073
|
+
var _this$updatingTargetL2;
|
|
1074
|
+
var updatingList = [].concat(_toConsumableArray((_this$updatingTargetL2 = this.updatingTargetList) !== null && _this$updatingTargetL2 !== void 0 ? _this$updatingTargetL2 : []), _toConsumableArray(this.hasAnimatingTargets() ? _toConsumableArray(this.animatingMap.keys()) : []));
|
|
1068
1075
|
var targets = [];
|
|
1069
|
-
var
|
|
1070
|
-
|
|
1076
|
+
var _iterator3 = _createForOfIteratorHelper(updatingList),
|
|
1077
|
+
_step3;
|
|
1071
1078
|
try {
|
|
1072
|
-
for (
|
|
1073
|
-
var
|
|
1074
|
-
|
|
1079
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1080
|
+
var _this$targetValues$ta2;
|
|
1081
|
+
var target = _step3.value;
|
|
1082
|
+
if (!this.isTargetImperative(target)) {
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
if (((_this$targetValues$ta2 = this.targetValues[target]) === null || _this$targetValues$ta2 === void 0 ? void 0 : _this$targetValues$ta2.originalTargetName) === originalTargetName) {
|
|
1075
1086
|
targets.push(target);
|
|
1076
1087
|
}
|
|
1077
1088
|
}
|
|
1078
1089
|
} catch (err) {
|
|
1079
|
-
|
|
1090
|
+
_iterator3.e(err);
|
|
1080
1091
|
} finally {
|
|
1081
|
-
|
|
1092
|
+
_iterator3.f();
|
|
1082
1093
|
}
|
|
1083
1094
|
return targets;
|
|
1084
1095
|
}
|
package/build/EventListener.js
CHANGED
|
@@ -59,6 +59,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
59
59
|
this.currentOriginalEvent = undefined;
|
|
60
60
|
this.currentKey = '';
|
|
61
61
|
this.currentHandlers = {
|
|
62
|
+
gestureTarget: null,
|
|
62
63
|
touch: null,
|
|
63
64
|
click: null,
|
|
64
65
|
scrollLeft: null,
|
|
@@ -71,6 +72,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
71
72
|
leave: null,
|
|
72
73
|
enter: null,
|
|
73
74
|
start: null,
|
|
75
|
+
endCandidate: null,
|
|
74
76
|
end: null,
|
|
75
77
|
hover: null
|
|
76
78
|
};
|
|
@@ -267,10 +269,21 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
267
269
|
value: function findEventHandlers(_ref) {
|
|
268
270
|
var tmodel = _ref.tmodel,
|
|
269
271
|
eventType = _ref.eventType;
|
|
270
|
-
var clickHandler
|
|
272
|
+
var clickHandler;
|
|
273
|
+
var swipeHandler;
|
|
274
|
+
var scrollLeftHandler;
|
|
275
|
+
var scrollTopHandler;
|
|
276
|
+
var pinchHandler;
|
|
277
|
+
var focusHandler;
|
|
278
|
+
var enterHandler;
|
|
279
|
+
var leaveHandler;
|
|
280
|
+
var startHandler;
|
|
281
|
+
var endHandler;
|
|
271
282
|
if (tmodel) {
|
|
272
283
|
clickHandler = SearchUtil.findFirstClickHandler(tmodel);
|
|
273
284
|
swipeHandler = SearchUtil.findFirstSwipeHandler(tmodel);
|
|
285
|
+
startHandler = SearchUtil.findFirstStartHandler(tmodel);
|
|
286
|
+
endHandler = SearchUtil.findFirstEndHandler(tmodel);
|
|
274
287
|
enterHandler = SearchUtil.findFirstEnterHandler(tmodel);
|
|
275
288
|
leaveHandler = SearchUtil.findFirstLeaveHandler(tmodel);
|
|
276
289
|
scrollLeftHandler = SearchUtil.findFirstScrollLeftHandler(tmodel, eventType);
|
|
@@ -288,6 +301,8 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
288
301
|
this.currentHandlers.hover = tmodel !== null && tmodel !== void 0 && tmodel.canHandleEvent('onHover') ? tmodel : undefined;
|
|
289
302
|
this.currentHandlers.click = clickHandler;
|
|
290
303
|
this.currentHandlers.swipe = swipeHandler;
|
|
304
|
+
this.currentHandlers.start = startHandler;
|
|
305
|
+
this.currentHandlers.endCandidate = endHandler;
|
|
291
306
|
this.currentHandlers.scrollLeft = scrollLeftHandler;
|
|
292
307
|
this.currentHandlers.scrollTop = scrollTopHandler;
|
|
293
308
|
this.currentHandlers.pinch = pinchHandler;
|
|
@@ -319,8 +334,10 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
319
334
|
this.findEventHandlers(lastEvent);
|
|
320
335
|
}
|
|
321
336
|
if (lastEvent.eventType === 'end') {
|
|
322
|
-
this.currentHandlers.end = this.currentHandlers.
|
|
337
|
+
this.currentHandlers.end = this.currentHandlers.endCandidate;
|
|
323
338
|
this.currentHandlers.start = undefined;
|
|
339
|
+
this.currentHandlers.endCandidate = undefined;
|
|
340
|
+
this.currentHandlers.gestureTarget = undefined;
|
|
324
341
|
}
|
|
325
342
|
this.currentEventName = lastEvent.eventName;
|
|
326
343
|
this.currentEventType = lastEvent.eventType;
|
|
@@ -331,6 +348,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
331
348
|
if (lastEvent.eventType === 'end' || lastEvent.eventType === 'click') {
|
|
332
349
|
this.canFindHandlers = true;
|
|
333
350
|
}
|
|
351
|
+
return lastEvent;
|
|
334
352
|
}
|
|
335
353
|
}, {
|
|
336
354
|
key: "markCapturedEventDirty",
|
|
@@ -401,8 +419,8 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
401
419
|
rateLimit = eventItem.rateLimit;
|
|
402
420
|
var now = TUtil.now();
|
|
403
421
|
var tmodel;
|
|
404
|
-
if (eventType === 'move' && this.touchCount > 0 && this.currentHandlers.
|
|
405
|
-
tmodel = this.currentHandlers.
|
|
422
|
+
if (eventType === 'move' && this.touchCount > 0 && this.currentHandlers.gestureTarget) {
|
|
423
|
+
tmodel = this.currentHandlers.gestureTarget;
|
|
406
424
|
} else {
|
|
407
425
|
tmodel = this.getTModelFromEvent(event);
|
|
408
426
|
}
|
|
@@ -468,7 +486,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
468
486
|
this.start1 = this.getTouch(event, 1);
|
|
469
487
|
this.cursor.x = this.start0.x;
|
|
470
488
|
this.cursor.y = this.start0.y;
|
|
471
|
-
this.currentHandlers.
|
|
489
|
+
this.currentHandlers.gestureTarget = tmodel;
|
|
472
490
|
this.findEventHandlers(newEvent);
|
|
473
491
|
this.canFindHandlers = false;
|
|
474
492
|
this.swipeStartX = this.start0.x - ((_this$currentHandlers = (_this$currentHandlers2 = this.currentHandlers.swipe) === null || _this$currentHandlers2 === void 0 ? void 0 : _this$currentHandlers2.getX()) !== null && _this$currentHandlers !== void 0 ? _this$currentHandlers : 0);
|
|
@@ -851,7 +869,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
851
869
|
}, {
|
|
852
870
|
key: "isSwipeEvent",
|
|
853
871
|
value: function isSwipeEvent() {
|
|
854
|
-
return this.hasDelta() && this.touchCount === 1;
|
|
872
|
+
return this.isMoveEvent() && this.hasDelta() && this.touchCount === 1;
|
|
855
873
|
}
|
|
856
874
|
}, {
|
|
857
875
|
key: "isScrollEvent",
|