targetj 1.0.216 → 1.0.218
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/README.md +8 -8
- package/build/AnimationManager.js +2 -2
- package/build/AnimationUtil.js +17 -1
- package/build/BaseModel.js +2 -0
- package/build/LocationManager.js +1 -1
- package/build/TModel.js +2 -2
- package/build/TModelUtil.js +171 -3
- package/build/TUtil.js +55 -0
- package/build/TargetData.js +5 -2
- package/build/TargetExecutor.js +2 -4
- package/build/TargetManager.js +5 -4
- package/build/TargetParser.js +1 -1
- package/build/TargetUtil.js +28 -124
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ It can be used as a full-featured framework or as a lightweight library alongsid
|
|
|
12
12
|
|
|
13
13
|
## The Philosophy Behind TargetJS
|
|
14
14
|
|
|
15
|
-
Traditional frameworks model the UI as a function of state: change state, re-render the UI. When state changes from A to B, the UI immediately jumps to
|
|
15
|
+
Traditional frameworks model the UI as a function of state: change state, re-render the UI. When state changes from A to B, the UI immediately jumps to B. The framework doesn’t naturally represent the *journey* from A to B. But modern, rich user experiences are journeys, not jumps. They are built on sequences that unfold over time. For example:
|
|
16
16
|
|
|
17
17
|
> Click → Animate button → Chain secondary animation → Fetch data → Render list → Animate items → Pause → Animate an important item
|
|
18
18
|
|
|
@@ -20,9 +20,9 @@ TargetJS is built for this reality. Instead of managing complex flags, your code
|
|
|
20
20
|
|
|
21
21
|
It achieves this through Targets. A Target is a self-contained unit that merges data (fields) and logic (methods) into a single reactive block. Each Target has its own internal state, timing, and lifecycle, acting like a living cell within your app. By simply ordering them in your code, you create complex asynchronous workflows without async/await or .then() chains.
|
|
22
22
|
|
|
23
|
-
In addition, animation is built directly into the framework
|
|
23
|
+
In addition, efficient animation is built directly into the framework using the Web Animations API, delivering CSS-level efficiency.
|
|
24
24
|
|
|
25
|
-
By adopting a compact style, TargetJS makes the journey from A to B explicit, with significantly less code than traditional frameworks.
|
|
25
|
+
By adopting a compact style, TargetJS makes the journey from A to B efficient and explicit, with significantly less code than traditional frameworks.
|
|
26
26
|
|
|
27
27
|
## ⚡ Quick Start (30 Seconds)
|
|
28
28
|
|
|
@@ -162,7 +162,7 @@ App({
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
},
|
|
165
|
-
fetch$$: { method: "POST", id: 123, url: "/api/like" }, // Wait for
|
|
165
|
+
fetch$$: { method: "POST", id: 123, url: "/api/like" }, // Wait for the heart to finish, THEN fetch
|
|
166
166
|
removeHearts$$() { this.removeChildren(); }, // Wait for fetch to finish, THEN cleanup
|
|
167
167
|
onKey(e) { if (e.key === "Enter") this.activateTarget("onClick"); }
|
|
168
168
|
}).mount("#likeButton");
|
|
@@ -170,7 +170,7 @@ App({
|
|
|
170
170
|
|
|
171
171
|
### Summary
|
|
172
172
|
|
|
173
|
-
Instead of wiring callbacks and effects, you write a sequence of targets. All targets execute automatically in the order they are written. `$$` defers execution until all prior sibling steps finish. Animations, API calls, event handling, and child creation are all treated as the same kind of thing: targets. Complex asynchronous flows are expressed by
|
|
173
|
+
Instead of wiring callbacks and effects, you write a sequence of targets. All targets execute automatically in the order they are written. `$$` defers execution until all prior sibling steps finish. Animations, API calls, event handling, and child creation are all treated as the same kind of thing: targets. Complex asynchronous flows are expressed by organizing work into parent and child targets. In addition, targets also provide built-in capabilities such as `onComplete` callback, enabledOn, looping with delays, and more as explained below.
|
|
174
174
|
|
|
175
175
|
---
|
|
176
176
|
|
|
@@ -178,7 +178,7 @@ Instead of wiring callbacks and effects, you write a sequence of targets. All ta
|
|
|
178
178
|
|
|
179
179
|
1. [📦 Alternative Installation Via CDN](#-alternative-installation-via-cdn)
|
|
180
180
|
1. [🚀 Why TargetJS?](#-why-targetjs)
|
|
181
|
-
1.
|
|
181
|
+
1. Deeer Examples:
|
|
182
182
|
- [Loading Five Users Example](#loading-five-users-example)
|
|
183
183
|
- [Infinite Loading and Scrolling Example](#infinite-loading-and-scrolling-example)
|
|
184
184
|
1. [Target Methods](#target-methods)
|
|
@@ -233,7 +233,7 @@ TargetJS can also be used as a "no-code" library. Elements with tg- attributes a
|
|
|
233
233
|
4. Ultra-Compact: Write 70% less code than standard frameworks.
|
|
234
234
|
5. Lower Cognitive Load: Code reads from top to bottom, exactly how the user experiences the interaction.
|
|
235
235
|
|
|
236
|
-
##
|
|
236
|
+
## Deeper Examples
|
|
237
237
|
|
|
238
238
|
### Loading Five Users Example
|
|
239
239
|
|
|
@@ -442,7 +442,7 @@ TargetJS maps directly to the DOM for zero-friction styling. For example:
|
|
|
442
442
|
|
|
443
443
|
TargetJS provides built-in debugging tools:
|
|
444
444
|
|
|
445
|
-
```
|
|
445
|
+
```javascript
|
|
446
446
|
TargetJS.tApp.stop(); // Stop the application.
|
|
447
447
|
TargetJS.tApp.start(); // Restart the application
|
|
448
448
|
TargetJS.tApp.throttle = 0; // Slow down execution (milliseconds between cycles)
|
|
@@ -88,7 +88,7 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
88
88
|
tmodel.tfMap[key] = tmodel.val(key);
|
|
89
89
|
});
|
|
90
90
|
var tfMap = _objectSpread(_objectSpread({}, tmodel.tfMap), frame.tfMap);
|
|
91
|
-
out.transform = _TModelUtil.TModelUtil.getTransformString(
|
|
91
|
+
out.transform = _TModelUtil.TModelUtil.getTransformString(tmodel, tfMap);
|
|
92
92
|
frame.tfMap = tfMap;
|
|
93
93
|
transformAnimation = true;
|
|
94
94
|
}
|
|
@@ -349,7 +349,7 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
349
349
|
});
|
|
350
350
|
var tfMap = _objectSpread(_objectSpread({}, tmodel.tfMap), frame0.tfMap);
|
|
351
351
|
frame0.tfMap = tfMap;
|
|
352
|
-
out.transform = _TModelUtil.TModelUtil.getTransformString(
|
|
352
|
+
out.transform = _TModelUtil.TModelUtil.getTransformString(tmodel, tfMap);
|
|
353
353
|
}
|
|
354
354
|
_AnimationUtil.AnimationUtil.addUnitsToFrame(out);
|
|
355
355
|
_AnimationUtil.AnimationUtil.fixStyleByAnimation(tmodel, out);
|
package/build/AnimationUtil.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.AnimationUtil = void 0;
|
|
7
7
|
var _TargetUtil = require("./TargetUtil.js");
|
|
8
8
|
var _TargetData = require("./TargetData.js");
|
|
9
|
+
var _TModelUtil = require("./TModelUtil.js");
|
|
9
10
|
var _App = require("./App.js");
|
|
10
11
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
12
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -83,7 +84,7 @@ var AnimationUtil = exports.AnimationUtil = /*#__PURE__*/function () {
|
|
|
83
84
|
keyMap: keyMap,
|
|
84
85
|
totalDuration: 1
|
|
85
86
|
};
|
|
86
|
-
(0, _App.getAnimationManager)().animate(tmodel, batch,
|
|
87
|
+
(0, _App.getAnimationManager)().animate(tmodel, batch, AnimationUtil.getAnimationHooks());
|
|
87
88
|
}
|
|
88
89
|
}, {
|
|
89
90
|
key: "fixStyleByAnimation",
|
|
@@ -143,5 +144,20 @@ var AnimationUtil = exports.AnimationUtil = /*#__PURE__*/function () {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "getAnimationHooks",
|
|
149
|
+
value: function getAnimationHooks() {
|
|
150
|
+
return {
|
|
151
|
+
morph: function morph(tm, key, from, to, step, steps) {
|
|
152
|
+
return _TModelUtil.TModelUtil.morph(tm, key, from, to, step, steps);
|
|
153
|
+
},
|
|
154
|
+
fireOnStep: function fireOnStep(tm, key, step) {
|
|
155
|
+
return (0, _App.getTargetManager)().fireOnStep(tm, key, step);
|
|
156
|
+
},
|
|
157
|
+
fireOnEnd: function fireOnEnd(tm, key) {
|
|
158
|
+
return (0, _App.getTargetManager)().fireOnEnd(tm, key);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
146
162
|
}]);
|
|
147
163
|
}();
|
package/build/BaseModel.js
CHANGED
|
@@ -192,6 +192,7 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
192
192
|
key: "initTargets",
|
|
193
193
|
value: function initTargets() {
|
|
194
194
|
var _this = this;
|
|
195
|
+
this.targetsVersion = 1;
|
|
195
196
|
this.originalTargetNames = Object.keys(this.targets).filter(function (key) {
|
|
196
197
|
return !_TargetData.TargetData.excludedTargetKeys.has(key);
|
|
197
198
|
});
|
|
@@ -252,6 +253,7 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
252
253
|
}, {
|
|
253
254
|
key: "processNewTarget",
|
|
254
255
|
value: function processNewTarget(key, keyIndex) {
|
|
256
|
+
this.targetsVersion++;
|
|
255
257
|
var cleanKey = _TargetUtil.TargetUtil.getTargetName(key);
|
|
256
258
|
var target = this.targets[key];
|
|
257
259
|
if (!_TUtil.TUtil.isDefined(target)) {
|
package/build/LocationManager.js
CHANGED
|
@@ -561,7 +561,7 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
561
561
|
}
|
|
562
562
|
var el = tmodel.$dom.getElement();
|
|
563
563
|
if (el && el.isConnected && document.visibilityState === 'visible') {
|
|
564
|
-
(0, _App.getAnimationManager)().animate(tmodel, batch,
|
|
564
|
+
(0, _App.getAnimationManager)().animate(tmodel, batch, _AnimationUtil.AnimationUtil.getAnimationHooks());
|
|
565
565
|
tmodel.pausedBatch = undefined;
|
|
566
566
|
}
|
|
567
567
|
}
|
package/build/TModel.js
CHANGED
|
@@ -428,8 +428,8 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
428
428
|
}
|
|
429
429
|
}, {
|
|
430
430
|
key: "getChild",
|
|
431
|
-
value: function getChild(
|
|
432
|
-
return typeof
|
|
431
|
+
value: function getChild(t) {
|
|
432
|
+
return typeof t === 'number' ? this.getChildren()[t] : this.findChild(t);
|
|
433
433
|
}
|
|
434
434
|
}, {
|
|
435
435
|
key: "getChildIndex",
|
package/build/TModelUtil.js
CHANGED
|
@@ -194,7 +194,7 @@ var TModelUtil = exports.TModelUtil = /*#__PURE__*/function () {
|
|
|
194
194
|
_iterator2.f();
|
|
195
195
|
}
|
|
196
196
|
if (transformUpdate) {
|
|
197
|
-
tmodel.$dom.transform(TModelUtil.getTransformString(tmodel
|
|
197
|
+
tmodel.$dom.transform(TModelUtil.getTransformString(tmodel, tmodel.tfMap));
|
|
198
198
|
}
|
|
199
199
|
tmodel.styleTargetMap.clear();
|
|
200
200
|
}
|
|
@@ -346,9 +346,167 @@ var TModelUtil = exports.TModelUtil = /*#__PURE__*/function () {
|
|
|
346
346
|
var n = Number(v);
|
|
347
347
|
return Number.isFinite(n) ? n : fallback;
|
|
348
348
|
}
|
|
349
|
+
}, {
|
|
350
|
+
key: "shouldUseImplicitTransformOrder",
|
|
351
|
+
value: function shouldUseImplicitTransformOrder(tmodel) {
|
|
352
|
+
var names = tmodel.originalTargetNames || [];
|
|
353
|
+
var hasAny = function hasAny(arr) {
|
|
354
|
+
return arr.some(function (k) {
|
|
355
|
+
return names.indexOf(k) >= 0;
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
var hasPerspective = hasAny(["perspective"]);
|
|
359
|
+
var hasTranslate = hasAny(["translateX", "translateY", "translateZ", "x", "y", "z"]);
|
|
360
|
+
var hasRotate = hasAny(["rotateX", "rotateY", "rotateZ"]) || hasAny(["rotate3DX"]) && hasAny(["rotate3DY"]) && hasAny(["rotate3DZ"]) && hasAny(["rotate3DAngle"]);
|
|
361
|
+
var hasSkew = hasAny(["skewX", "skewY"]);
|
|
362
|
+
var hasScale = hasAny(["scaleX", "scaleY", "scaleZ"]) || hasAny(["scale3DX"]) && hasAny(["scale3DY"]) && hasAny(["scale3DZ"]);
|
|
363
|
+
var groups = 0;
|
|
364
|
+
if (hasPerspective) {
|
|
365
|
+
groups++;
|
|
366
|
+
}
|
|
367
|
+
if (hasTranslate) {
|
|
368
|
+
groups++;
|
|
369
|
+
}
|
|
370
|
+
if (hasRotate) {
|
|
371
|
+
groups++;
|
|
372
|
+
}
|
|
373
|
+
if (hasSkew) {
|
|
374
|
+
groups++;
|
|
375
|
+
}
|
|
376
|
+
if (hasScale) {
|
|
377
|
+
groups++;
|
|
378
|
+
}
|
|
379
|
+
return groups > 1;
|
|
380
|
+
}
|
|
381
|
+
}, {
|
|
382
|
+
key: "buildImplicitTransformOrderMap",
|
|
383
|
+
value: function buildImplicitTransformOrderMap(names) {
|
|
384
|
+
var has = function has(k) {
|
|
385
|
+
return names.indexOf(k) >= 0;
|
|
386
|
+
};
|
|
387
|
+
var firstIdx = function firstIdx(candidates) {
|
|
388
|
+
var best = Infinity;
|
|
389
|
+
var _iterator4 = _createForOfIteratorHelper(candidates),
|
|
390
|
+
_step4;
|
|
391
|
+
try {
|
|
392
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
393
|
+
var c = _step4.value;
|
|
394
|
+
var i = names.indexOf(c);
|
|
395
|
+
if (i >= 0 && i < best) {
|
|
396
|
+
best = i;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
} catch (err) {
|
|
400
|
+
_iterator4.e(err);
|
|
401
|
+
} finally {
|
|
402
|
+
_iterator4.f();
|
|
403
|
+
}
|
|
404
|
+
return best;
|
|
405
|
+
};
|
|
406
|
+
var hasExplicitTranslate = has("translateX") || has("translateY") || has("translateZ");
|
|
407
|
+
var hasXYZ = has("x") || has("y") || has("z");
|
|
408
|
+
var hasRotate3d = has("rotate3DX") && has("rotate3DY") && has("rotate3DZ") && has("rotate3DAngle");
|
|
409
|
+
var hasScale3d = has("scale3DX") && has("scale3DY") && has("scale3DZ");
|
|
410
|
+
var hasBothSkew = has("skewX") && has("skewY");
|
|
411
|
+
var groups = [];
|
|
412
|
+
if (has("perspective")) {
|
|
413
|
+
groups.push({
|
|
414
|
+
group: "perspective",
|
|
415
|
+
order: firstIdx(["perspective"]),
|
|
416
|
+
outputs: ["perspective"]
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
if (hasExplicitTranslate) {
|
|
420
|
+
groups.push({
|
|
421
|
+
group: "translate",
|
|
422
|
+
order: firstIdx(["translateX", "translateY", "translateZ"]),
|
|
423
|
+
outputs: ["translateX", "translateY", "translateZ"].filter(has)
|
|
424
|
+
});
|
|
425
|
+
} else if (hasXYZ) {
|
|
426
|
+
groups.push({
|
|
427
|
+
group: "translate",
|
|
428
|
+
order: firstIdx(["x", "y", "z"]),
|
|
429
|
+
outputs: ["translate3d"]
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
if (hasRotate3d) {
|
|
433
|
+
groups.push({
|
|
434
|
+
group: "rotate",
|
|
435
|
+
order: firstIdx(["rotate3DX", "rotate3DY", "rotate3DZ", "rotate3DAngle"]),
|
|
436
|
+
outputs: ["rotate3d"]
|
|
437
|
+
});
|
|
438
|
+
} else {
|
|
439
|
+
var rotKeys = ["rotateX", "rotateY", "rotateZ", "rotate"];
|
|
440
|
+
var rotPresent = rotKeys.filter(has);
|
|
441
|
+
if (rotPresent.length) {
|
|
442
|
+
groups.push({
|
|
443
|
+
group: "rotate",
|
|
444
|
+
order: firstIdx(rotKeys),
|
|
445
|
+
outputs: rotPresent
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (hasBothSkew) {
|
|
450
|
+
groups.push({
|
|
451
|
+
group: "skew",
|
|
452
|
+
order: firstIdx(["skewX", "skewY"]),
|
|
453
|
+
outputs: ["skew"]
|
|
454
|
+
});
|
|
455
|
+
} else {
|
|
456
|
+
var skewPresent = ["skewX", "skewY"].filter(has);
|
|
457
|
+
if (skewPresent.length) {
|
|
458
|
+
groups.push({
|
|
459
|
+
group: "skew",
|
|
460
|
+
order: firstIdx(["skewX", "skewY"]),
|
|
461
|
+
outputs: skewPresent
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (hasScale3d) {
|
|
466
|
+
groups.push({
|
|
467
|
+
group: "scale",
|
|
468
|
+
order: firstIdx(["scale3DX", "scale3DY", "scale3DZ"]),
|
|
469
|
+
outputs: ["scale3d"]
|
|
470
|
+
});
|
|
471
|
+
} else {
|
|
472
|
+
var scaleKeys = ["scaleX", "scaleY", "scaleZ", "scale"];
|
|
473
|
+
var scalePresent = scaleKeys.filter(has);
|
|
474
|
+
if (scalePresent.length) {
|
|
475
|
+
groups.push({
|
|
476
|
+
group: "scale",
|
|
477
|
+
order: firstIdx(scaleKeys),
|
|
478
|
+
outputs: scalePresent
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
var tieRank = {
|
|
483
|
+
perspective: 0,
|
|
484
|
+
translate: 1,
|
|
485
|
+
rotate: 2,
|
|
486
|
+
skew: 3,
|
|
487
|
+
scale: 4
|
|
488
|
+
};
|
|
489
|
+
groups.sort(function (a, b) {
|
|
490
|
+
var _tieRank$a$group, _tieRank$b$group;
|
|
491
|
+
var oa = Number.isFinite(a.order) ? a.order : Infinity;
|
|
492
|
+
var ob = Number.isFinite(b.order) ? b.order : Infinity;
|
|
493
|
+
if (oa !== ob) {
|
|
494
|
+
return oa - ob;
|
|
495
|
+
}
|
|
496
|
+
return ((_tieRank$a$group = tieRank[a.group]) !== null && _tieRank$a$group !== void 0 ? _tieRank$a$group : 999) - ((_tieRank$b$group = tieRank[b.group]) !== null && _tieRank$b$group !== void 0 ? _tieRank$b$group : 999);
|
|
497
|
+
});
|
|
498
|
+
var orderList = groups.flatMap(function (g) {
|
|
499
|
+
return g.outputs;
|
|
500
|
+
});
|
|
501
|
+
var map = {};
|
|
502
|
+
orderList.forEach(function (k, i) {
|
|
503
|
+
return map[k] = i;
|
|
504
|
+
});
|
|
505
|
+
return map;
|
|
506
|
+
}
|
|
349
507
|
}, {
|
|
350
508
|
key: "getTransformString",
|
|
351
|
-
value: function getTransformString(
|
|
509
|
+
value: function getTransformString(tmodel, values) {
|
|
352
510
|
var processed = {};
|
|
353
511
|
var transformMap = {};
|
|
354
512
|
var hasExplicitTranslate = _TUtil.TUtil.isDefined(values.translateX) || _TUtil.TUtil.isDefined(values.translateY) || _TUtil.TUtil.isDefined(values.translateZ);
|
|
@@ -442,12 +600,22 @@ var TModelUtil = exports.TModelUtil = /*#__PURE__*/function () {
|
|
|
442
600
|
}
|
|
443
601
|
}
|
|
444
602
|
var orderMap = {};
|
|
603
|
+
var transformOrderList = tmodel.val('transformOrder');
|
|
445
604
|
if (Array.isArray(transformOrderList) && transformOrderList.length) {
|
|
446
605
|
transformOrderList.forEach(function (name, index) {
|
|
447
606
|
orderMap[name] = index;
|
|
448
607
|
});
|
|
449
608
|
} else {
|
|
450
|
-
|
|
609
|
+
if (TModelUtil.shouldUseImplicitTransformOrder(tmodel)) {
|
|
610
|
+
if (tmodel.implicitTransformOrderVersion !== tmodel.targetsVersion) {
|
|
611
|
+
tmodel.implicitTransformOrderMap = TModelUtil.buildImplicitTransformOrderMap(tmodel.originalTargetNames);
|
|
612
|
+
tmodel.implicitTransformOrderVersion = tmodel.targetsVersion;
|
|
613
|
+
}
|
|
614
|
+
orderMap = tmodel.implicitTransformOrderMap;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (!Object.keys(orderMap).length && Object.keys(transformMap).length) {
|
|
618
|
+
orderMap = _TargetData.TargetData.transformOrder;
|
|
451
619
|
}
|
|
452
620
|
var sortedKeys = Object.keys(transformMap).sort(function (a, b) {
|
|
453
621
|
var _orderMap$a, _orderMap$b;
|
package/build/TUtil.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TUtil = void 0;
|
|
7
7
|
var _App = require("./App.js");
|
|
8
|
+
var _TargetUtil = require("./TargetUtil.js");
|
|
9
|
+
var _TargetData = require("./TargetData.js");
|
|
8
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
9
11
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
12
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
@@ -254,6 +256,59 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
|
|
|
254
256
|
return t.oid;
|
|
255
257
|
}));
|
|
256
258
|
}
|
|
259
|
+
}, {
|
|
260
|
+
key: "handleValueChange",
|
|
261
|
+
value: function handleValueChange(tmodel, key) {
|
|
262
|
+
var target = tmodel.targets[key];
|
|
263
|
+
if (!target) {
|
|
264
|
+
key = _TargetUtil.TargetUtil.getTargetName(key);
|
|
265
|
+
target = tmodel.targets[key];
|
|
266
|
+
}
|
|
267
|
+
var newValue = tmodel.val(key);
|
|
268
|
+
var lastValue = tmodel.lastVal(key);
|
|
269
|
+
if (_typeof(target) === 'object' && typeof target.onValueChange === 'function') {
|
|
270
|
+
var valueChanged = !TUtil.areEqual(newValue, lastValue, target.deepEquality);
|
|
271
|
+
if (valueChanged) {
|
|
272
|
+
target.onValueChange.call(tmodel, newValue, lastValue, tmodel.getTargetCycle(key));
|
|
273
|
+
tmodel.setTargetMethodName(key, 'onValueChange');
|
|
274
|
+
}
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}, {
|
|
280
|
+
key: "scheduleExecution",
|
|
281
|
+
value: function scheduleExecution(tmodel, key) {
|
|
282
|
+
var interval = tmodel.getTargetInterval(key);
|
|
283
|
+
var now = TUtil.now();
|
|
284
|
+
if (interval <= 0) {
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
if (tmodel.isTargetImperative(key) && tmodel.getTargetStep(key) === 0) {
|
|
288
|
+
tmodel.setScheduleTimeStamp(key, now);
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
291
|
+
var lastScheduledTime = tmodel.getScheduleTimeStamp(key);
|
|
292
|
+
if (TUtil.isDefined(lastScheduledTime)) {
|
|
293
|
+
var elapsed = now - lastScheduledTime;
|
|
294
|
+
return Math.max(interval - elapsed, 0);
|
|
295
|
+
}
|
|
296
|
+
tmodel.setScheduleTimeStamp(key, now);
|
|
297
|
+
return interval;
|
|
298
|
+
}
|
|
299
|
+
}, {
|
|
300
|
+
key: "runTargetValue",
|
|
301
|
+
value: function runTargetValue(tmodel, target, key, cycle, lastValue) {
|
|
302
|
+
var cleanKey = _TargetUtil.TargetUtil.getTargetName(key);
|
|
303
|
+
var isExternalEvent = _TargetData.TargetData.allEventMap[cleanKey];
|
|
304
|
+
if (isExternalEvent) {
|
|
305
|
+
return typeof target.value === 'function' ? target.value.call(tmodel, (0, _App.getEvents)().getCurrentOriginalEvent(), cycle, lastValue) : TUtil.isDefined(target.value) ? target.value : target;
|
|
306
|
+
} else if (tmodel.val("___".concat(key))) {
|
|
307
|
+
return typeof target.value === 'function' ? target.value.call(tmodel, tmodel.val("___".concat(key)), cycle, lastValue) : TUtil.isDefined(target.value) ? target.value : target;
|
|
308
|
+
} else {
|
|
309
|
+
return typeof target.value === 'function' ? target.value.call(tmodel, cycle, lastValue) : TUtil.isDefined(target.value) ? target.value : target;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
257
312
|
}, {
|
|
258
313
|
key: "mergeTargets",
|
|
259
314
|
value: function mergeTargets(tmodel1, tmodel2) {
|
package/build/TargetData.js
CHANGED
|
@@ -211,7 +211,9 @@ _defineProperty(TargetData, "asyncStyleTargetMap", {
|
|
|
211
211
|
backgroundSize: true,
|
|
212
212
|
flexWrap: true,
|
|
213
213
|
userSelect: true,
|
|
214
|
-
outline: true
|
|
214
|
+
outline: true,
|
|
215
|
+
backfaceVisibility: true,
|
|
216
|
+
filter: true
|
|
215
217
|
});
|
|
216
218
|
_defineProperty(TargetData, "scaleMap", {
|
|
217
219
|
scale: true,
|
|
@@ -761,7 +763,8 @@ _defineProperty(TargetData, "attributesToTargets", {
|
|
|
761
763
|
arialabel: 'ariaLabel',
|
|
762
764
|
ariacurrent: 'ariaCurrent',
|
|
763
765
|
ariapressed: 'ariaPressed',
|
|
764
|
-
tabindex: 'tabIndex'
|
|
766
|
+
tabindex: 'tabIndex',
|
|
767
|
+
backfacevisibility: 'backfaceVisibility'
|
|
765
768
|
});
|
|
766
769
|
_defineProperty(TargetData, "targetToEventsMapping", {
|
|
767
770
|
onStart: ['touchStart', 'mouseStart'],
|
package/build/TargetExecutor.js
CHANGED
|
@@ -56,9 +56,7 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
|
|
|
56
56
|
tmodel.allTargetMap[cleanKey] = key;
|
|
57
57
|
TargetExecutor.resolveTargetValue(tmodel, key);
|
|
58
58
|
TargetExecutor.updateTarget(tmodel, tmodel.targetValues[key], key, false);
|
|
59
|
-
|
|
60
|
-
_TargetUtil.TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
61
|
-
}
|
|
59
|
+
_TargetUtil.TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
62
60
|
}
|
|
63
61
|
}, {
|
|
64
62
|
key: "assignImperativeTargetValue",
|
|
@@ -229,7 +227,7 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
|
|
|
229
227
|
if (!tmodel.hasValidAnimation() || !tmodel.canBeAnimated(key)) {
|
|
230
228
|
tmodel.val(key, newValue);
|
|
231
229
|
tmodel.setActual(key, newValue);
|
|
232
|
-
|
|
230
|
+
_TUtil.TUtil.handleValueChange(tmodel, key);
|
|
233
231
|
return;
|
|
234
232
|
}
|
|
235
233
|
_AnimationUtil.AnimationUtil.overrideAnimatedKeyWithSnap(tmodel, key, newValue);
|
package/build/TargetManager.js
CHANGED
|
@@ -11,6 +11,7 @@ var _TargetUtil = require("./TargetUtil.js");
|
|
|
11
11
|
var _TModelUtil = require("./TModelUtil.js");
|
|
12
12
|
var _SearchUtil = require("./SearchUtil.js");
|
|
13
13
|
var _TargetData = require("./TargetData.js");
|
|
14
|
+
var _AnimationUtil = require("./AnimationUtil.js");
|
|
14
15
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
15
16
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
16
17
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -62,7 +63,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
62
63
|
if (tmodel.isScheduledPending(key)) {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
|
-
var schedulePeriod =
|
|
66
|
+
var schedulePeriod = _TUtil.TUtil.scheduleExecution(tmodel, key);
|
|
66
67
|
if (schedulePeriod > 0) {
|
|
67
68
|
(0, _App.getRunScheduler)().timeSchedule(schedulePeriod, "targetSchedule__".concat(tmodel.oid, "__").concat(key, "_").concat(schedulePeriod));
|
|
68
69
|
return;
|
|
@@ -91,7 +92,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
91
92
|
try {
|
|
92
93
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
93
94
|
var key = _step2.value;
|
|
94
|
-
schedulePeriod =
|
|
95
|
+
schedulePeriod = _TUtil.TUtil.scheduleExecution(tmodel, key);
|
|
95
96
|
if (schedulePeriod > 0) {
|
|
96
97
|
(0, _App.getRunScheduler)().schedule(schedulePeriod, "setActualValues-".concat(tmodel.oid, "__").concat(key, "_").concat(schedulePeriod));
|
|
97
98
|
} else {
|
|
@@ -109,7 +110,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
109
110
|
tmodel.waapiBatch = undefined;
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
|
-
(0, _App.getAnimationManager)().animate(tmodel, batch,
|
|
113
|
+
(0, _App.getAnimationManager)().animate(tmodel, batch, _AnimationUtil.AnimationUtil.getAnimationHooks());
|
|
113
114
|
tmodel.waapiBatch = undefined;
|
|
114
115
|
}
|
|
115
116
|
}, {
|
|
@@ -155,7 +156,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
} else {
|
|
158
|
-
needsRefire =
|
|
159
|
+
needsRefire = _TUtil.TUtil.handleValueChange(tmodel, key);
|
|
159
160
|
if (target !== null && target !== void 0 && target.activateNextTarget && !target.activateNextTarget.endsWith('$$') && target.activateNextTarget.endsWith('$')) {
|
|
160
161
|
needsRefire = true;
|
|
161
162
|
_TargetUtil.TargetUtil.shouldActivateNextTarget(tmodel, key);
|
package/build/TargetParser.js
CHANGED
|
@@ -260,7 +260,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
260
260
|
|
|
261
261
|
// Plain objects: compute value + params (steps/interval/easing/cycles)
|
|
262
262
|
if (_typeof(target) === "object" && target !== null && Object.getPrototypeOf(target) === Object.prototype) {
|
|
263
|
-
var valueResult =
|
|
263
|
+
var valueResult = _TUtil.TUtil.runTargetValue(tmodel, target, key, cycle, lastValue);
|
|
264
264
|
if (TargetParser.isPrimitiveArray(valueResult) && (_TUtil.TUtil.isDefined(target.steps) || _TUtil.TUtil.isDefined(target.interval) || _TUtil.TUtil.isDefined(target.easing) || _TUtil.TUtil.isDefined(target.cycles))) {
|
|
265
265
|
value = {
|
|
266
266
|
list: valueResult
|