targetj 1.0.228 → 1.0.230
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 +17 -17
- package/build/AnimationManager.js +39 -31
- package/build/BaseModel.js +5 -3
- package/build/Bracket.js +9 -18
- package/build/BracketGenerator.js +22 -1
- package/build/LoadingManager.js +2 -6
- package/build/LocationManager.js +19 -27
- package/build/TModel.js +14 -12
- package/build/TModelManager.js +55 -15
- package/build/TUtil.js +90 -35
- package/build/TargetData.js +8 -2
- package/build/TargetExecutor.js +8 -5
- package/build/TargetManager.js +2 -2
- package/build/TargetParser.js +3 -2
- package/build/TargetUtil.js +7 -2
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/livetrails/targetjs/stargazers)
|
|
6
6
|
[](https://www.npmjs.com/package/targetj)
|
|
7
7
|
|
|
8
|
-
TargetJS is a high-performance JavaScript UI framework with ultra-compact syntax. It replaces the "State → Render" model with
|
|
8
|
+
TargetJS is a high-performance JavaScript UI framework with ultra-compact syntax. It replaces the "State → Render" model with "State → transition → Render". It unifies UI, animations, APIs, event handling, and state into self-contained "Targets" that stack together like intelligent Lego pieces using Code-Ordered Reactivity.
|
|
9
9
|
|
|
10
10
|
It can be used as a full-featured framework or as a lightweight library alongside other frameworks. It is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ It can be used as a full-featured framework or as a lightweight library alongsid
|
|
|
16
16
|
|
|
17
17
|
Traditional frameworks model the UI as a function of state: change state, re-render the UI. When state changes from A → B, the UI immediately jumps to B. The framework doesn’t naturally represent the journey from A → B. But modern, rich user experiences are more like: A → transition → B.
|
|
18
18
|
|
|
19
|
-
TargetJS treats state as a destination. Values are not only assigned. They can be approached over time through configurable steps. This makes transitions a native part of state change
|
|
19
|
+
TargetJS treats state as a destination. Values are not only assigned. They can be approached over time through configurable steps. This makes transitions a native part of state change. TargetJS also delivers CSS-level transition efficiency.
|
|
20
20
|
|
|
21
21
|
**Fragmentation across multiple mental models**
|
|
22
22
|
|
|
@@ -34,7 +34,7 @@ In traditional code, that sequence is often scattered across different places su
|
|
|
34
34
|
|
|
35
35
|
TargetJS code order and target reactivity allow the implementation to more closely mirror the actual UI sequence.
|
|
36
36
|
|
|
37
|
-
With its compact style, TargetJS makes the journey from A → B
|
|
37
|
+
With its compact style, TargetJS makes the journey from A → B explicit and efficient, with significantly less code than traditional frameworks.
|
|
38
38
|
|
|
39
39
|
## ⚡ Quick Start (30 Seconds)
|
|
40
40
|
|
|
@@ -53,17 +53,17 @@ import { App } from "targetj";
|
|
|
53
53
|
|
|
54
54
|
App({
|
|
55
55
|
backgroundColor: 'blue', // Starts immediately
|
|
56
|
-
width: { value: [100, 200], steps: 100 }, // Starts immediately: animate width from 100px to 200px in 100 steps with 8 ms interval per step.
|
|
57
|
-
height: { value: [100, 200], steps: 100 }, // Starts immediately: animate height.
|
|
58
|
-
backgroundColor$$: { value: 'red', steps: 100 }, // Wait ($$) for width/height to finish
|
|
59
|
-
done$$() { console.log("Hello World!"); } // 3. Waits ($$) for the background color
|
|
56
|
+
width: { value: [100, 200], steps: 100, interval: 8 }, // Starts immediately: animate width from 100px to 200px in 100 steps with 8 ms interval per step.
|
|
57
|
+
height: { value: [100, 200], steps: 100, interval: 8 }, // Starts immediately: animate height.
|
|
58
|
+
backgroundColor$$: { value: 'red', steps: 100, interval: 8 }, // Wait ($$) for width/height to finish
|
|
59
|
+
done$$() { console.log("Hello World!"); } // 3. Waits ($$) for the background color, width/height to finish
|
|
60
60
|
}).mount("#app");
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
## Targets
|
|
64
64
|
|
|
65
|
-
In TargetJS, targets are the fundamental unit of behavior.
|
|
66
|
-
Methods
|
|
65
|
+
In TargetJS, targets are the fundamental unit of behavior instead of methods.
|
|
66
|
+
Methods and properties both are internally transformed into targets that the framework schedules and executes.
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
### Execution Syntax
|
|
@@ -89,6 +89,7 @@ A target can also be defined as an object with optional controls that manage its
|
|
|
89
89
|
| `interval` | Delay (ms) between steps or executions. |
|
|
90
90
|
| `cycles` | Number of times the target repeats. |
|
|
91
91
|
| `loop` | Boolean form of repetition for continuous execution. |
|
|
92
|
+
| `active` | Boolean property controlling when `value` is executed. |
|
|
92
93
|
| `enabledOn` | Determines whether the target is enabled for execution. |
|
|
93
94
|
| `easing` | Predefined easing function controlling how values update over steps. |
|
|
94
95
|
| `onComplete` | Callback triggered when this target (and its children) finishes. |
|
|
@@ -96,7 +97,7 @@ A target can also be defined as an object with optional controls that manage its
|
|
|
96
97
|
|
|
97
98
|
## Examples: Like Button → Animated Like (in 3 Steps)
|
|
98
99
|
|
|
99
|
-
Let’s see how TargetJS handles a complex interaction that would usually require 50+ lines of React/CSS. The example demonstrates how to run four asynchronous operations in a strict sequential sequence,
|
|
100
|
+
Let’s see how TargetJS handles a complex interaction that would usually require 50+ lines of React/CSS. The example demonstrates how to run four asynchronous operations in a strict sequential sequence. In other words, each step has to wait for all the previous ones to complete.
|
|
100
101
|
|
|
101
102
|
### 1) Like button
|
|
102
103
|
|
|
@@ -257,7 +258,7 @@ TargetJS can run inside an existing app mounted into a DOM element managed by an
|
|
|
257
258
|
|
|
258
259
|
```javascript
|
|
259
260
|
import React, { useLayoutEffect, useRef } from "react";
|
|
260
|
-
import { App as
|
|
261
|
+
import { App as TApp } from "targetj";
|
|
261
262
|
|
|
262
263
|
export default function TargetIsland() {
|
|
263
264
|
const hostRef = useRef(null);
|
|
@@ -266,7 +267,7 @@ export default function TargetIsland() {
|
|
|
266
267
|
const el = hostRef.current;
|
|
267
268
|
if (!el) return;
|
|
268
269
|
|
|
269
|
-
|
|
270
|
+
TApp({
|
|
270
271
|
width: { value: [100, 500], steps: 100 },
|
|
271
272
|
height: 200,
|
|
272
273
|
backgroundColor: "purple",
|
|
@@ -274,7 +275,7 @@ export default function TargetIsland() {
|
|
|
274
275
|
}).mount(el);
|
|
275
276
|
|
|
276
277
|
return () => {
|
|
277
|
-
|
|
278
|
+
TApp.unmount();
|
|
278
279
|
};
|
|
279
280
|
}, []);
|
|
280
281
|
|
|
@@ -409,7 +410,6 @@ App({
|
|
|
409
410
|
bottomMargin: 8,
|
|
410
411
|
borderRadius: 12,
|
|
411
412
|
backgroundColor: "white",
|
|
412
|
-
validateVisibilityInParent: true,
|
|
413
413
|
boxShadow: "0 8px 20px rgba(0,0,0,0.08)",
|
|
414
414
|
photo: {
|
|
415
415
|
x: 10, y: 10, width: 34, height: 34,
|
|
@@ -501,9 +501,9 @@ TargetJS.tApp.start(); // Restart the application
|
|
|
501
501
|
TargetJS.tApp.throttle = 0; // Slow down execution (milliseconds between cycles)
|
|
502
502
|
TargetJS.tApp.debugLevel = 1; // Log cycle execution
|
|
503
503
|
```
|
|
504
|
-
- Use `t()` in the browser console to find an object by its
|
|
505
|
-
- Use `t(
|
|
506
|
-
- Use `t(
|
|
504
|
+
- Use `t(id)` in the browser console to find an object by its element id.
|
|
505
|
+
- Use `t(id).bug()` to inspect all the vital properties.
|
|
506
|
+
- Use `t(id).logTree()` to inspect the UI structure.
|
|
507
507
|
|
|
508
508
|
## Documentation
|
|
509
509
|
Explore the potential of TargetJS and dive into our interactive documentation at www.targetjs.io.
|
|
@@ -47,7 +47,6 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
47
47
|
return _createClass(AnimationManager, [{
|
|
48
48
|
key: "animate",
|
|
49
49
|
value: function animate(tmodel, batch, hooks) {
|
|
50
|
-
var _this = this;
|
|
51
50
|
if (this.isShuttingDown || !tmodel.hasDom()) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
@@ -132,6 +131,9 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
132
131
|
hooks: hooks
|
|
133
132
|
};
|
|
134
133
|
tmodel.addToAnimatingMap(_originalKey, rec);
|
|
134
|
+
if (tmodel.targetValues[_originalKey]) {
|
|
135
|
+
tmodel.targetValues[_originalKey].status = 'updating';
|
|
136
|
+
}
|
|
135
137
|
this.recordMap.set(recId, rec);
|
|
136
138
|
}
|
|
137
139
|
} catch (err) {
|
|
@@ -139,16 +141,6 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
139
141
|
} finally {
|
|
140
142
|
_iterator2.f();
|
|
141
143
|
}
|
|
142
|
-
var finalize = function finalize() {
|
|
143
|
-
_this.finalizeAnimation(anim);
|
|
144
|
-
};
|
|
145
|
-
anim.addEventListener("finish", finalize, {
|
|
146
|
-
once: true
|
|
147
|
-
});
|
|
148
|
-
anim.addEventListener("cancel", finalize, {
|
|
149
|
-
once: true
|
|
150
|
-
});
|
|
151
|
-
anim.finished.then(finalize).catch(finalize);
|
|
152
144
|
this.startProgressPoller();
|
|
153
145
|
}
|
|
154
146
|
}, {
|
|
@@ -208,11 +200,12 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
208
200
|
} finally {
|
|
209
201
|
_iterator3.f();
|
|
210
202
|
}
|
|
203
|
+
(0, _App.getRunScheduler)().schedule(35, "finalizeAnimation");
|
|
211
204
|
}
|
|
212
205
|
}, {
|
|
213
206
|
key: "startProgressPoller",
|
|
214
207
|
value: function startProgressPoller() {
|
|
215
|
-
var
|
|
208
|
+
var _this = this;
|
|
216
209
|
if (this.waapiPoller.rafId) {
|
|
217
210
|
return;
|
|
218
211
|
}
|
|
@@ -220,7 +213,7 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
220
213
|
var _tick = function tick() {
|
|
221
214
|
var animsToFinalize = new Set();
|
|
222
215
|
var hasPlaying = false;
|
|
223
|
-
var _iterator4 = _createForOfIteratorHelper(
|
|
216
|
+
var _iterator4 = _createForOfIteratorHelper(_this.recordMap),
|
|
224
217
|
_step4;
|
|
225
218
|
try {
|
|
226
219
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
@@ -232,7 +225,7 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
232
225
|
} else if (record.status === 'playing') {
|
|
233
226
|
hasPlaying = true;
|
|
234
227
|
}
|
|
235
|
-
|
|
228
|
+
_this.updateTModelFromRecord(record);
|
|
236
229
|
var ps = record.anim.playState;
|
|
237
230
|
var ct = (_record$anim$effect = record.anim.effect) === null || _record$anim$effect === void 0 || (_record$anim$effect$g = (_record$anim$effect2 = _record$anim$effect).getComputedTiming) === null || _record$anim$effect$g === void 0 ? void 0 : _record$anim$effect$g.call(_record$anim$effect2);
|
|
238
231
|
var finished = ps === "finished" || ps === "idle" || ct && ct.progress >= 0.999999;
|
|
@@ -251,18 +244,18 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
251
244
|
try {
|
|
252
245
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
253
246
|
var anim = _step5.value;
|
|
254
|
-
|
|
247
|
+
_this.finalizeAnimation(anim);
|
|
255
248
|
}
|
|
256
249
|
} catch (err) {
|
|
257
250
|
_iterator5.e(err);
|
|
258
251
|
} finally {
|
|
259
252
|
_iterator5.f();
|
|
260
253
|
}
|
|
261
|
-
if (
|
|
262
|
-
|
|
254
|
+
if (_this.recordMap.size > 0 || hasPlaying) {
|
|
255
|
+
_this.waapiPoller.rafId = requestAnimationFrame(_tick);
|
|
263
256
|
} else {
|
|
264
|
-
|
|
265
|
-
|
|
257
|
+
_this.waapiPoller.alive = false;
|
|
258
|
+
_this.waapiPoller.rafId = 0;
|
|
266
259
|
}
|
|
267
260
|
};
|
|
268
261
|
this.waapiPoller.rafId = requestAnimationFrame(_tick);
|
|
@@ -765,6 +758,21 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
765
758
|
if (!batch) {
|
|
766
759
|
return;
|
|
767
760
|
}
|
|
761
|
+
var _iterator15 = _createForOfIteratorHelper(tmodel.animatingMap),
|
|
762
|
+
_step15;
|
|
763
|
+
try {
|
|
764
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
765
|
+
var _step15$value = _slicedToArray(_step15.value, 1),
|
|
766
|
+
key = _step15$value[0];
|
|
767
|
+
if (tmodel.targetValues[key]) {
|
|
768
|
+
tmodel.targetValues[key].status = 'pause';
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
} catch (err) {
|
|
772
|
+
_iterator15.e(err);
|
|
773
|
+
} finally {
|
|
774
|
+
_iterator15.f();
|
|
775
|
+
}
|
|
768
776
|
var cutTime = Math.min(_TUtil.TUtil.now() - batch.startTime, batch.totalDuration);
|
|
769
777
|
this.cutLastBatch(tmodel, batch, cutTime);
|
|
770
778
|
tmodel.pausedBatch = batch;
|
|
@@ -814,22 +822,22 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
814
822
|
return;
|
|
815
823
|
}
|
|
816
824
|
var keySet = new Set(cleanKeys);
|
|
817
|
-
var
|
|
818
|
-
|
|
825
|
+
var _iterator16 = _createForOfIteratorHelper(el.getAnimations()),
|
|
826
|
+
_step16;
|
|
819
827
|
try {
|
|
820
|
-
for (
|
|
821
|
-
var anim =
|
|
828
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
829
|
+
var anim = _step16.value;
|
|
822
830
|
var effect = anim.effect;
|
|
823
831
|
if (!(effect !== null && effect !== void 0 && effect.getKeyframes)) {
|
|
824
832
|
continue;
|
|
825
833
|
}
|
|
826
834
|
var kfs = effect.getKeyframes();
|
|
827
835
|
var touches = false;
|
|
828
|
-
var
|
|
829
|
-
|
|
836
|
+
var _iterator17 = _createForOfIteratorHelper(kfs),
|
|
837
|
+
_step17;
|
|
830
838
|
try {
|
|
831
|
-
for (
|
|
832
|
-
var kf =
|
|
839
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
840
|
+
var kf = _step17.value;
|
|
833
841
|
for (var _i5 = 0, _Object$keys2 = Object.keys(kf); _i5 < _Object$keys2.length; _i5++) {
|
|
834
842
|
var k = _Object$keys2[_i5];
|
|
835
843
|
if (keySet.has(k)) {
|
|
@@ -842,9 +850,9 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
842
850
|
}
|
|
843
851
|
}
|
|
844
852
|
} catch (err) {
|
|
845
|
-
|
|
853
|
+
_iterator17.e(err);
|
|
846
854
|
} finally {
|
|
847
|
-
|
|
855
|
+
_iterator17.f();
|
|
848
856
|
}
|
|
849
857
|
if (touches) {
|
|
850
858
|
try {
|
|
@@ -853,9 +861,9 @@ var AnimationManager = exports.AnimationManager = /*#__PURE__*/function () {
|
|
|
853
861
|
}
|
|
854
862
|
}
|
|
855
863
|
} catch (err) {
|
|
856
|
-
|
|
864
|
+
_iterator16.e(err);
|
|
857
865
|
} finally {
|
|
858
|
-
|
|
866
|
+
_iterator16.f();
|
|
859
867
|
}
|
|
860
868
|
}
|
|
861
869
|
}]);
|
package/build/BaseModel.js
CHANGED
|
@@ -498,10 +498,11 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
498
498
|
return;
|
|
499
499
|
}
|
|
500
500
|
var oldStatus = targetValue.status;
|
|
501
|
-
if (status === 'done' && oldStatus !== 'done' && oldStatus !== 'complete') {
|
|
501
|
+
if (status === 'done' && oldStatus !== 'done' && oldStatus !== 'complete' && !targetValue.resetFlag) {
|
|
502
502
|
targetValue.completeCount++;
|
|
503
503
|
targetValue.completeTime = _TUtil.TUtil.now();
|
|
504
504
|
}
|
|
505
|
+
targetValue.resetFlag = false;
|
|
505
506
|
targetValue.status = status;
|
|
506
507
|
if (targetValue.status === 'fetching') {
|
|
507
508
|
this.removeFromActiveTargets(key);
|
|
@@ -675,7 +676,8 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
675
676
|
if (t.loop !== undefined) {
|
|
676
677
|
var loop = typeof t.loop === 'function' ? t.loop.call(this, key) : t.loop;
|
|
677
678
|
if (loop === 'passive') {
|
|
678
|
-
|
|
679
|
+
var values = _TargetParser.TargetParser.getValueStepsCycles(this, key);
|
|
680
|
+
return values[0] === this.getTargetValue(key) ? false : true;
|
|
679
681
|
}
|
|
680
682
|
}
|
|
681
683
|
return true;
|
|
@@ -696,7 +698,7 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
696
698
|
key: "getDimLastUpdate",
|
|
697
699
|
value: function getDimLastUpdate() {
|
|
698
700
|
var _this$getLastUpdate, _this$getLastUpdate2, _this$getLastUpdate3, _this$domHeightTimest, _this$domWidthTimesta;
|
|
699
|
-
return Math.max((_this$getLastUpdate = this.getLastUpdate('width')) !== null && _this$getLastUpdate !== void 0 ? _this$getLastUpdate : 0, (_this$getLastUpdate2 = this.getLastUpdate('height')) !== null && _this$getLastUpdate2 !== void 0 ? _this$getLastUpdate2 : 0, (_this$getLastUpdate3 = this.getLastUpdate('
|
|
701
|
+
return Math.max((_this$getLastUpdate = this.getLastUpdate('width')) !== null && _this$getLastUpdate !== void 0 ? _this$getLastUpdate : 0, (_this$getLastUpdate2 = this.getLastUpdate('height')) !== null && _this$getLastUpdate2 !== void 0 ? _this$getLastUpdate2 : 0, (_this$getLastUpdate3 = this.getLastUpdate('dim')) !== null && _this$getLastUpdate3 !== void 0 ? _this$getLastUpdate3 : 0, (_this$domHeightTimest = this.domHeightTimestamp) !== null && _this$domHeightTimest !== void 0 ? _this$domHeightTimest : 0, (_this$domWidthTimesta = this.domWidthTimestamp) !== null && _this$domWidthTimesta !== void 0 ? _this$domWidthTimesta : 0);
|
|
700
702
|
}
|
|
701
703
|
}, {
|
|
702
704
|
key: "getTargetActivationTime",
|
package/build/Bracket.js
CHANGED
|
@@ -29,6 +29,7 @@ var Bracket = exports.Bracket = /*#__PURE__*/function (_TModel) {
|
|
|
29
29
|
_classCallCheck(this, Bracket);
|
|
30
30
|
_this = _callSuper(this, Bracket, ["BI"]);
|
|
31
31
|
_this.parent = parent;
|
|
32
|
+
_this.currentBrakcetStatus = 2;
|
|
32
33
|
return _this;
|
|
33
34
|
}
|
|
34
35
|
_inherits(Bracket, _TModel);
|
|
@@ -157,33 +158,23 @@ var Bracket = exports.Bracket = /*#__PURE__*/function (_TModel) {
|
|
|
157
158
|
}, {
|
|
158
159
|
key: "shouldCalculateChildren",
|
|
159
160
|
value: function shouldCalculateChildren() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
this.currentStatus = undefined;
|
|
165
|
-
if (visibleChild) {
|
|
166
|
-
this.currentStatus = 'new';
|
|
167
|
-
var parent = this.parent;
|
|
168
|
-
while (parent && parent.type === 'BI') {
|
|
169
|
-
parent.currentStatus = 'new';
|
|
170
|
-
parent = parent.parent;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
161
|
+
var nowVisible = this.isVisible();
|
|
162
|
+
if (this.currentBrakcetStatus >= 1 || this.isNowVisible || this.isNowInvisible) {
|
|
163
|
+
this.currentBrakcetStatus = Math.max(0, this.currentBrakcetStatus - 1);
|
|
173
164
|
return true;
|
|
174
165
|
}
|
|
166
|
+
if (nowVisible) {
|
|
167
|
+
this.currentBrakcetStatus = Math.min(2, this.currentBrakcetStatus + 1);
|
|
168
|
+
}
|
|
175
169
|
if (this.getDirtyLayout() === false) {
|
|
176
170
|
return false;
|
|
177
171
|
}
|
|
178
|
-
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
return false;
|
|
172
|
+
return nowVisible;
|
|
182
173
|
}
|
|
183
174
|
}, {
|
|
184
175
|
key: "getDirtyLayout",
|
|
185
176
|
value: function getDirtyLayout() {
|
|
186
|
-
return this.getRealParent().managesOwnScroll ? this.getRealParent().backupDirtyLayout : this.dirtyLayout;
|
|
177
|
+
return this.getRealParent().managesOwnScroll() ? this.getRealParent().backupDirtyLayout : this.dirtyLayout;
|
|
187
178
|
}
|
|
188
179
|
}, {
|
|
189
180
|
key: "validateVisibilityInParent",
|
|
@@ -71,6 +71,7 @@ var BracketGenerator = exports.BracketGenerator = /*#__PURE__*/function () {
|
|
|
71
71
|
var _index = parent.allChildrenList.indexOf(child);
|
|
72
72
|
if (_index >= 0) {
|
|
73
73
|
parent.allChildrenList.splice(_index, 1);
|
|
74
|
+
BracketGenerator.markBracketDirty(parent);
|
|
74
75
|
if (parent.allChildrenList.length === 0) {
|
|
75
76
|
deleteChildRecursively(parent.parent, parent);
|
|
76
77
|
}
|
|
@@ -145,11 +146,13 @@ var BracketGenerator = exports.BracketGenerator = /*#__PURE__*/function () {
|
|
|
145
146
|
bracket.startIndex = Math.min(bracket.startIndex, index);
|
|
146
147
|
bracket.endIndex = bracket.startIndex + bracket.allChildrenList.length;
|
|
147
148
|
bracket.currentStatus = 'new';
|
|
149
|
+
bracket.markLayoutDirty('update');
|
|
148
150
|
bracket = targetBracket.getParent();
|
|
149
151
|
while (bracket instanceof _Bracket.Bracket) {
|
|
150
152
|
bracket.startIndex = Math.min(bracket.startIndex, index);
|
|
151
153
|
bracket.endIndex = Math.max(bracket.endIndex, index + 1);
|
|
152
154
|
bracket.currentStatus = 'new';
|
|
155
|
+
bracket.markLayoutDirty('update');
|
|
153
156
|
bracket = bracket.getParent();
|
|
154
157
|
}
|
|
155
158
|
if (targetBracket.allChildrenList.length > bracketSize) {
|
|
@@ -178,11 +181,13 @@ var BracketGenerator = exports.BracketGenerator = /*#__PURE__*/function () {
|
|
|
178
181
|
var _bracket$parent$allCh;
|
|
179
182
|
(_bracket$parent$allCh = bracket.parent.allChildrenList).splice.apply(_bracket$parent$allCh, [index, 1].concat(chunks));
|
|
180
183
|
}
|
|
184
|
+
BracketGenerator.markBracketDirty(bracket);
|
|
181
185
|
if (bracket.parent.allChildrenList.length >= bracketSize) {
|
|
182
186
|
var rebuiltChildren = BracketGenerator.buildTreeBottomUp(page, bracket.parent.allChildrenList);
|
|
183
187
|
bracket.parent.allChildrenList = rebuiltChildren;
|
|
184
188
|
bracket.parent.allChildrenList.forEach(function (child) {
|
|
185
189
|
child.parent = bracket.parent;
|
|
190
|
+
BracketGenerator.markBracketDirty(child);
|
|
186
191
|
});
|
|
187
192
|
|
|
188
193
|
// Update grandparent relationships
|
|
@@ -207,6 +212,12 @@ var BracketGenerator = exports.BracketGenerator = /*#__PURE__*/function () {
|
|
|
207
212
|
BracketGenerator.bracketMap[page.oid] = BracketGenerator.buildTreeBottomUp(page, topBrackets);
|
|
208
213
|
}
|
|
209
214
|
}
|
|
215
|
+
chunks.forEach(function (chunk) {
|
|
216
|
+
return BracketGenerator.markBracketDirty(chunk);
|
|
217
|
+
});
|
|
218
|
+
if (chunks[0].parent instanceof _Bracket.Bracket) {
|
|
219
|
+
BracketGenerator.markBracketDirty(chunks[0].parent);
|
|
220
|
+
}
|
|
210
221
|
}
|
|
211
222
|
}, {
|
|
212
223
|
key: "findOrCreateBracket",
|
|
@@ -233,7 +244,7 @@ var BracketGenerator = exports.BracketGenerator = /*#__PURE__*/function () {
|
|
|
233
244
|
brackets.push(newBracket);
|
|
234
245
|
if (brackets.length > page.getBracketSize()) {
|
|
235
246
|
var topBrackets = BracketGenerator.buildTreeBottomUp(page, brackets);
|
|
236
|
-
BracketGenerator.bracketMap[page.oid]
|
|
247
|
+
BracketGenerator.bracketMap[page.oid] = topBrackets;
|
|
237
248
|
}
|
|
238
249
|
return newBracket;
|
|
239
250
|
}
|
|
@@ -280,6 +291,16 @@ var BracketGenerator = exports.BracketGenerator = /*#__PURE__*/function () {
|
|
|
280
291
|
BracketGenerator.pageMap = {};
|
|
281
292
|
BracketGenerator.all = {};
|
|
282
293
|
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "markBracketDirty",
|
|
296
|
+
value: function markBracketDirty(bracket) {
|
|
297
|
+
var current = bracket;
|
|
298
|
+
while (current && current.type === 'BI') {
|
|
299
|
+
current.currentStatus = 'new';
|
|
300
|
+
current.markLayoutDirty('update');
|
|
301
|
+
current = current.parent;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
283
304
|
}]);
|
|
284
305
|
}();
|
|
285
306
|
_defineProperty(BracketGenerator, "bracketMap", {});
|
package/build/LoadingManager.js
CHANGED
|
@@ -133,7 +133,7 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
|
|
|
133
133
|
var key = this.getTModelKey(tmodel, targetName);
|
|
134
134
|
var loadTargetName = _TUtil.TUtil.getLoadTargetName(targetName);
|
|
135
135
|
var loadingComplete = this.isLoadingComplete(tmodel, targetName);
|
|
136
|
-
if (loadingComplete || !this.tmodelKeyMap[key]) {
|
|
136
|
+
if (loadingComplete || !this.tmodelKeyMap[key] || !tmodel.val(loadTargetName)) {
|
|
137
137
|
var _this$tmodelKeyMap, _this$tmodelKeyMap$ke;
|
|
138
138
|
(_this$tmodelKeyMap$ke = (_this$tmodelKeyMap = this.tmodelKeyMap)[key]) !== null && _this$tmodelKeyMap$ke !== void 0 ? _this$tmodelKeyMap$ke : _this$tmodelKeyMap[key] = {
|
|
139
139
|
fetchMap: {},
|
|
@@ -143,11 +143,7 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
|
|
|
143
143
|
activeIndex: 0,
|
|
144
144
|
accessIndex: 0
|
|
145
145
|
};
|
|
146
|
-
|
|
147
|
-
if (loadingComplete || !tmodel.val(loadTargetName)) {
|
|
148
|
-
if (!tmodel.val(loadTargetName)) {
|
|
149
|
-
tmodel.val(loadTargetName, []);
|
|
150
|
-
}
|
|
146
|
+
tmodel.val(loadTargetName, []);
|
|
151
147
|
}
|
|
152
148
|
if (!this.tmodelKeyMap[key].fetchMap[fetchId]) {
|
|
153
149
|
this.tmodelKeyMap[key].fetchMap[fetchId] = {
|
package/build/LocationManager.js
CHANGED
|
@@ -228,7 +228,7 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
viewport.setCurrentChild(child);
|
|
231
|
-
if (!child.getDirtyLayout() && !child.currentStatus) {
|
|
231
|
+
if (!child.getDirtyLayout() && !child.currentStatus && child.activeTargetList.length === 0) {
|
|
232
232
|
_this.calcNextLocation(child, container, viewport);
|
|
233
233
|
job.index++;
|
|
234
234
|
return;
|
|
@@ -244,7 +244,7 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
244
244
|
var prevX = child.actualValues.x;
|
|
245
245
|
var prevY = child.actualValues.y;
|
|
246
246
|
var prevWidth = child.getMinWidth();
|
|
247
|
-
if (child.isIncluded()
|
|
247
|
+
if (child.isIncluded()) {
|
|
248
248
|
_this.calculateTargets(child);
|
|
249
249
|
}
|
|
250
250
|
if (prevWidth !== child.getMinWidth() && viewport.isOverflow()) {
|
|
@@ -289,12 +289,6 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
289
289
|
viewport: undefined,
|
|
290
290
|
index: 0
|
|
291
291
|
});
|
|
292
|
-
} else if (!child.isVisible() && child.makeChildrenInvisible !== false) {
|
|
293
|
-
child.makeChildrenInvisible = false;
|
|
294
|
-
_TUtil.TUtil.getDeepList(child).forEach(function (t) {
|
|
295
|
-
t.actualValues.isVisible = false;
|
|
296
|
-
_this.addToLocationList(t);
|
|
297
|
-
});
|
|
298
292
|
}
|
|
299
293
|
}
|
|
300
294
|
};
|
|
@@ -401,8 +395,7 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
401
395
|
}, {
|
|
402
396
|
key: "calcNextLocation",
|
|
403
397
|
value: function calcNextLocation(child, container, viewport) {
|
|
404
|
-
var _child$styleTargetMap
|
|
405
|
-
_this2 = this;
|
|
398
|
+
var _child$styleTargetMap;
|
|
406
399
|
viewport.setLocation();
|
|
407
400
|
if (viewport.isOverflow()) {
|
|
408
401
|
viewport.overflow();
|
|
@@ -433,12 +426,6 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
433
426
|
this.addToLocationList(child);
|
|
434
427
|
}
|
|
435
428
|
this.calculateVisibility(child);
|
|
436
|
-
if (!child.isVisible() && child.hasChildren()) {
|
|
437
|
-
_TUtil.TUtil.getDeepList(child).forEach(function (t) {
|
|
438
|
-
t.actualValues.isVisible = false;
|
|
439
|
-
_this2.addToLocationList(t);
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
429
|
if (child.isInFlow()) {
|
|
443
430
|
if (_TUtil.TUtil.isNumber(child.val('appendNewLine'))) {
|
|
444
431
|
viewport.appendNewLine();
|
|
@@ -455,24 +442,29 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
455
442
|
var wasVisible = tmodel.isVisible();
|
|
456
443
|
var nowVisible;
|
|
457
444
|
var lastVisibleTest = (_tmodel$visibilitySta = (_tmodel$visibilitySta2 = tmodel.visibilityStatus) === null || _tmodel$visibilitySta2 === void 0 ? void 0 : _tmodel$visibilitySta2.isVisible) !== null && _tmodel$visibilitySta !== void 0 ? _tmodel$visibilitySta : undefined;
|
|
458
|
-
|
|
445
|
+
if (!tmodel.visibilityStatus) {
|
|
446
|
+
tmodel.visibilityStatus = {};
|
|
447
|
+
}
|
|
448
|
+
tmodel.visibilityStatus.lastIsVisible = tmodel.visibilityStatus.isVisible;
|
|
459
449
|
if (_TUtil.TUtil.isDefined(tmodel.targets.isVisible)) {
|
|
460
450
|
if (typeof tmodel.targets.isVisible.value === 'function') {
|
|
461
451
|
nowVisible = tmodel.targets.isVisible.value.call(tmodel);
|
|
462
452
|
} else {
|
|
463
453
|
nowVisible = !!tmodel.targets.isVisible;
|
|
464
454
|
}
|
|
455
|
+
tmodel.isNowVisible = !wasVisible && nowVisible;
|
|
456
|
+
tmodel.isNowInvisible = (wasVisible || wasVisible === undefined) && !nowVisible;
|
|
465
457
|
} else {
|
|
458
|
+
var nowVisibleTest = tmodel.calcVisibility();
|
|
466
459
|
nowVisible = nowVisibleTest;
|
|
460
|
+
tmodel.isNowVisible = !wasVisible && nowVisible || !lastVisibleTest && nowVisibleTest;
|
|
461
|
+
tmodel.isNowInvisible = (wasVisible || wasVisible === undefined) && !nowVisible || lastVisibleTest && !nowVisibleTest;
|
|
462
|
+
tmodel.actualValues.isVisible = nowVisible;
|
|
467
463
|
}
|
|
468
|
-
tmodel.
|
|
469
|
-
tmodel.isNowVisible = !wasVisible && nowVisible || !lastVisibleTest && nowVisibleTest;
|
|
470
|
-
tmodel.isNowInvisible = (wasVisible || wasVisible === undefined) && !nowVisible || lastVisibleTest && !nowVisibleTest;
|
|
471
|
-
if (tmodel.isNowVisible) {
|
|
464
|
+
if (tmodel.isNowVisible || tmodel.isNowInvisible) {
|
|
472
465
|
tmodel.markLayoutDirty('isNowVisible');
|
|
473
466
|
}
|
|
474
467
|
if (tmodel.isNowInvisible) {
|
|
475
|
-
tmodel.makeChildrenInvisible = undefined;
|
|
476
468
|
this.addToLocationList(tmodel);
|
|
477
469
|
}
|
|
478
470
|
tmodel.addToParentVisibleChildren();
|
|
@@ -529,17 +521,17 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
529
521
|
}, {
|
|
530
522
|
key: "scheduleResumePaused",
|
|
531
523
|
value: function scheduleResumePaused() {
|
|
532
|
-
var
|
|
524
|
+
var _this2 = this;
|
|
533
525
|
if (this.resumeScheduled || !this.resumePausedList.length) {
|
|
534
526
|
return;
|
|
535
527
|
}
|
|
536
528
|
this.resumeScheduled = true;
|
|
537
529
|
requestAnimationFrame(function () {
|
|
538
530
|
requestAnimationFrame(function () {
|
|
539
|
-
|
|
540
|
-
var list =
|
|
541
|
-
|
|
542
|
-
|
|
531
|
+
_this2.resumeScheduled = false;
|
|
532
|
+
var list = _this2.resumePausedList.slice();
|
|
533
|
+
_this2.resumePausedList.length = 0;
|
|
534
|
+
_this2.resumePausedMap = {};
|
|
543
535
|
var _iterator2 = _createForOfIteratorHelper(list),
|
|
544
536
|
_step2;
|
|
545
537
|
try {
|
package/build/TModel.js
CHANGED
|
@@ -70,18 +70,17 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
70
70
|
return _createClass(TModel, [{
|
|
71
71
|
key: "createViewport",
|
|
72
72
|
value: function createViewport() {
|
|
73
|
+
var _this$getParent$$dom$, _this$getParent, _this$getParent$$dom$2, _this$getParent2;
|
|
73
74
|
this.viewport = this.viewport || new _Viewport.Viewport();
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
var x = scrollLeft,
|
|
77
|
-
y = scrollTop;
|
|
75
|
+
var x = -this.getScrollLeft(),
|
|
76
|
+
y = -this.getScrollTop();
|
|
78
77
|
this.viewport.xNext = x;
|
|
79
78
|
this.viewport.xNorth = x;
|
|
80
79
|
this.viewport.xEast = x;
|
|
81
80
|
this.viewport.xSouth = x;
|
|
82
81
|
this.viewport.xWest = x;
|
|
83
|
-
this.viewport.scrollLeft =
|
|
84
|
-
this.viewport.scrollTop =
|
|
82
|
+
this.viewport.scrollLeft = -(this.getScrollLeft() + ((_this$getParent$$dom$ = (_this$getParent = this.getParent()) === null || _this$getParent === void 0 || (_this$getParent = _this$getParent.$dom) === null || _this$getParent === void 0 ? void 0 : _this$getParent.getScrollLeft()) !== null && _this$getParent$$dom$ !== void 0 ? _this$getParent$$dom$ : 0));
|
|
83
|
+
this.viewport.scrollTop = -(this.getScrollTop() + ((_this$getParent$$dom$2 = (_this$getParent2 = this.getParent()) === null || _this$getParent2 === void 0 || (_this$getParent2 = _this$getParent2.$dom) === null || _this$getParent2 === void 0 ? void 0 : _this$getParent2.getScrollTop()) !== null && _this$getParent$$dom$2 !== void 0 ? _this$getParent$$dom$2 : 0));
|
|
85
84
|
this.viewport.absX = this.absX;
|
|
86
85
|
this.viewport.absY = this.absY;
|
|
87
86
|
this.viewport.xOverflowReset = x;
|
|
@@ -115,9 +114,8 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
115
114
|
}, {
|
|
116
115
|
key: "calcAbsolutePosition",
|
|
117
116
|
value: function calcAbsolutePosition(x, y) {
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
this.absY = _TUtil.TUtil.isDefined(this.val('absY')) ? this.val('absY') : this.getParent().absY - ((_this$getParent$$dom$2 = (_this$getParent$$dom2 = this.getParent().$dom) === null || _this$getParent$$dom2 === void 0 ? void 0 : _this$getParent$$dom2.getScrollTop()) !== null && _this$getParent$$dom$2 !== void 0 ? _this$getParent$$dom$2 : 0) + y;
|
|
117
|
+
this.absX = _TUtil.TUtil.isDefined(this.val('absX')) ? this.val('absX') : this.getParent().absX + x;
|
|
118
|
+
this.absY = _TUtil.TUtil.isDefined(this.val('absY')) ? this.val('absY') : this.getParent().absY + y;
|
|
121
119
|
}
|
|
122
120
|
}, {
|
|
123
121
|
key: "calcAbsolutePositionFromDom",
|
|
@@ -415,7 +413,11 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
415
413
|
if (!this.isIncluded() || this.isDomIsland() && !this.hasDom()) {
|
|
416
414
|
return false;
|
|
417
415
|
}
|
|
418
|
-
var
|
|
416
|
+
var hasDirtyLayout = this.dirtyLayout !== false;
|
|
417
|
+
var hasDirtyEvent = this.hasEventDirty();
|
|
418
|
+
var hasDom = this.hasDom();
|
|
419
|
+
var visible = this.isVisible();
|
|
420
|
+
var result = this.currentStatus === 'active' || hasDirtyLayout || visible && hasDirtyEvent || this.isNowVisible || hasDom && hasDirtyEvent;
|
|
419
421
|
this.currentStatus = undefined;
|
|
420
422
|
return result;
|
|
421
423
|
}
|
|
@@ -494,8 +496,8 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
494
496
|
value: function getParentValueAtMyIndex(targetName) {
|
|
495
497
|
var parentValue = this.getParentValue(targetName);
|
|
496
498
|
if (Array.isArray(parentValue)) {
|
|
497
|
-
var _this$
|
|
498
|
-
var index = (_this$
|
|
499
|
+
var _this$getParent3;
|
|
500
|
+
var index = (_this$getParent3 = this.getParent()) === null || _this$getParent3 === void 0 ? void 0 : _this$getParent3.getChildIndex(this);
|
|
499
501
|
if (typeof index === 'number') {
|
|
500
502
|
return parentValue[index];
|
|
501
503
|
}
|