targetj 1.0.110 → 1.0.111
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 +31 -70
- package/build/$Dom.js +2 -2
- package/build/EventListener.js +52 -22
- package/build/LocationManager.js +16 -13
- package/build/SearchUtil.js +17 -4
- package/build/TModel.js +56 -32
- package/build/TargetUtil.js +7 -1
- package/build/Viewport.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,78 +184,39 @@ In the example below, we define a target named load. Inside the value function,
|
|
|
184
184
|
|
|
185
185
|
In this example, we set the cycles to 9, triggering the API call 10 times at intervals of 1 second (interval set to 1000). Each API response is appended as a separate object in the output. Because we didn’t specify the fourth argument, the response is always fetched directly from the API rather than from the cache.
|
|
186
186
|
|
|
187
|
-

|
|
188
188
|
|
|
189
189
|
```bash
|
|
190
190
|
import { App, TModel, getLoader, getScreenHeight, getScreenWidth, Moves } from "targetj";
|
|
191
191
|
|
|
192
|
-
App(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
onSuccess(res) {
|
|
203
|
-
this.addChild(new TModel("user", {
|
|
204
|
-
bounce: {
|
|
205
|
-
loop: true,
|
|
206
|
-
value() {
|
|
207
|
-
this.setTarget("move",
|
|
208
|
-
Moves.bounceSimple(this, {
|
|
209
|
-
xStart: this.getX() || Math.random() * 300,
|
|
210
|
-
yStart: 200,
|
|
211
|
-
from: 0,
|
|
212
|
-
to: 200,
|
|
213
|
-
widthStart: 50,
|
|
214
|
-
heightStart: 50,
|
|
215
|
-
}), 20);
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
lineHeight: 50,
|
|
219
|
-
textAlign: "center",
|
|
220
|
-
html: res.result.name,
|
|
221
|
-
background: "yellow",
|
|
222
|
-
})
|
|
223
|
-
);
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
})
|
|
227
|
-
);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
## Event handling example
|
|
231
|
-
|
|
232
|
-
In the following example, the background color of the pane changes randomly whenever you click on it. The `canHandleEvents` target ensures that the object can handle touch events, such as clicks. However, we’ve set a limit of 10 executions for the background change. After reaching this limit, the component will no longer respond to click events. The `onClickEvent` is a system target that activates all associated targets when a click occurs. The `html` target tracks the number of executions and displays it within the pane.
|
|
233
|
-
|
|
234
|
-

|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
import { App, TModel } from "targetj";
|
|
238
|
-
|
|
239
|
-
App(
|
|
240
|
-
new TModel("events", {
|
|
241
|
-
canHandleEvents() {
|
|
242
|
-
return this.getTargetExecutionCount("background") < 10 ? "touch" : "";
|
|
243
|
-
},
|
|
244
|
-
width: 120,
|
|
245
|
-
height: 120,
|
|
246
|
-
background: {
|
|
247
|
-
active: false,
|
|
248
|
-
initialValue: "#f00",
|
|
249
|
-
value() {
|
|
250
|
-
return "#" + Math.random().toString(16).slice(-6);
|
|
251
|
-
},
|
|
192
|
+
App(new TModel("apiCall", {
|
|
193
|
+
width: 160,
|
|
194
|
+
height: getScreenHeight,
|
|
195
|
+
load: {
|
|
196
|
+
interval: 1000,
|
|
197
|
+
cycles: 8,
|
|
198
|
+
value: function (cycle) {
|
|
199
|
+
return getLoader().fetch(this, "https://targetj.io/api/randomUser", {
|
|
200
|
+
id: `user${cycle}`,
|
|
201
|
+
});
|
|
252
202
|
},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
203
|
+
onSuccess(res) {
|
|
204
|
+
this.addChild(
|
|
205
|
+
new TModel("user", {
|
|
206
|
+
lineHeight: 50,
|
|
207
|
+
textAlign: "center",
|
|
208
|
+
html: res.result.name,
|
|
209
|
+
width: 50,
|
|
210
|
+
height: 50,
|
|
211
|
+
rightMargin: 5,
|
|
212
|
+
bottomMargin: 5,
|
|
213
|
+
color: "#fff",
|
|
214
|
+
background: "#B388FF",
|
|
215
|
+
})
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
259
220
|
```
|
|
260
221
|
|
|
261
222
|
## Animation API example
|
|
@@ -360,14 +321,14 @@ import { App, TModel, getEvents, getScreenHeight, getScreenWidth, } from "target
|
|
|
360
321
|
|
|
361
322
|
App(new TModel("scroller", {
|
|
362
323
|
canHandleEvents: "scrollTop",
|
|
363
|
-
|
|
324
|
+
containerOverflowMode: 'always',
|
|
364
325
|
children: {
|
|
365
326
|
value() {
|
|
366
327
|
const childrenCount = this.getChildren().length;
|
|
367
328
|
return Array.from({ length: 5 }, (_, i) =>
|
|
368
329
|
new TModel("scrollItem", {
|
|
369
330
|
width: 300,
|
|
370
|
-
background: "
|
|
331
|
+
background: "#B388FF",
|
|
371
332
|
height: 30,
|
|
372
333
|
color: "#fff",
|
|
373
334
|
textAlign: "center",
|
|
@@ -418,7 +379,7 @@ App(new TModel("simpleApp", {
|
|
|
418
379
|
width: 100,
|
|
419
380
|
height: 50,
|
|
420
381
|
lineHeight: 50,
|
|
421
|
-
|
|
382
|
+
itemOverflowMode: 'never',
|
|
422
383
|
opacity: 0.5,
|
|
423
384
|
cursor: "pointer",
|
|
424
385
|
html: menu,
|
package/build/$Dom.js
CHANGED
|
@@ -85,11 +85,11 @@ var $Dom = exports.$Dom = /*#__PURE__*/function () {
|
|
|
85
85
|
if (!this.element) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
+
var currentValue = this.element.value;
|
|
88
89
|
if (_TUtil.TUtil.isDefined(_value)) {
|
|
89
90
|
this.element.value = _value;
|
|
90
|
-
} else {
|
|
91
|
-
return this.element.value;
|
|
92
91
|
}
|
|
92
|
+
return currentValue;
|
|
93
93
|
}
|
|
94
94
|
}, {
|
|
95
95
|
key: "select",
|
package/build/EventListener.js
CHANGED
|
@@ -34,7 +34,9 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
34
34
|
this.touchTimeStamp = 0;
|
|
35
35
|
this.cursor = {
|
|
36
36
|
x: 0,
|
|
37
|
-
y: 0
|
|
37
|
+
y: 0,
|
|
38
|
+
handlerX: 0,
|
|
39
|
+
handlerY: 0
|
|
38
40
|
};
|
|
39
41
|
this.start0 = undefined;
|
|
40
42
|
this.start1 = undefined;
|
|
@@ -282,7 +284,6 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
282
284
|
} else if (diff > 600) {
|
|
283
285
|
this.clearTouch();
|
|
284
286
|
this.touchTimeStamp = 0;
|
|
285
|
-
this.touchCount = 0;
|
|
286
287
|
}
|
|
287
288
|
(0, _App.getRunScheduler)().schedule(runDelay, "scroll decay");
|
|
288
289
|
}
|
|
@@ -290,12 +291,13 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
290
291
|
}, {
|
|
291
292
|
key: "findEventHandlers",
|
|
292
293
|
value: function findEventHandlers(_ref) {
|
|
293
|
-
var tmodel = _ref.tmodel
|
|
294
|
+
var tmodel = _ref.tmodel,
|
|
295
|
+
eventType = _ref.eventType;
|
|
294
296
|
var touchHandler, scrollLeftHandler, scrollTopHandler, pinchHandler, focusHandler;
|
|
295
297
|
if (tmodel) {
|
|
296
298
|
touchHandler = _SearchUtil.SearchUtil.findFirstTouchHandler(tmodel);
|
|
297
|
-
scrollLeftHandler = _SearchUtil.SearchUtil.findFirstScrollLeftHandler(tmodel);
|
|
298
|
-
scrollTopHandler = _SearchUtil.SearchUtil.findFirstScrollTopHandler(tmodel);
|
|
299
|
+
scrollLeftHandler = _SearchUtil.SearchUtil.findFirstScrollLeftHandler(tmodel, eventType);
|
|
300
|
+
scrollTopHandler = _SearchUtil.SearchUtil.findFirstScrollTopHandler(tmodel, eventType);
|
|
299
301
|
pinchHandler = _SearchUtil.SearchUtil.findFirstPinchHandler(tmodel);
|
|
300
302
|
focusHandler = _$Dom.$Dom.hasFocus(tmodel) ? tmodel : this.currentHandlers.focus;
|
|
301
303
|
}
|
|
@@ -330,7 +332,9 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
330
332
|
return;
|
|
331
333
|
}
|
|
332
334
|
var lastEvent = this.eventQueue.shift();
|
|
333
|
-
this.
|
|
335
|
+
if (this.touchCount === 0) {
|
|
336
|
+
this.findEventHandlers(lastEvent);
|
|
337
|
+
}
|
|
334
338
|
this.currentEventName = lastEvent.eventName;
|
|
335
339
|
this.currentEventType = lastEvent.eventType;
|
|
336
340
|
this.currentKey = this.currentTouch.key;
|
|
@@ -373,15 +377,16 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
}
|
|
380
|
+
var newEvent = {
|
|
381
|
+
eventName: eventName,
|
|
382
|
+
eventItem: eventItem,
|
|
383
|
+
eventType: eventType,
|
|
384
|
+
originalName: originalName,
|
|
385
|
+
tmodel: tmodel,
|
|
386
|
+
timeStamp: now
|
|
387
|
+
};
|
|
376
388
|
if (queue) {
|
|
377
|
-
this.eventQueue.push(
|
|
378
|
-
eventName: eventName,
|
|
379
|
-
eventItem: eventItem,
|
|
380
|
-
eventType: eventType,
|
|
381
|
-
originalName: originalName,
|
|
382
|
-
tmodel: tmodel,
|
|
383
|
-
timeStamp: now
|
|
384
|
-
});
|
|
389
|
+
this.eventQueue.push(newEvent);
|
|
385
390
|
}
|
|
386
391
|
switch (eventName) {
|
|
387
392
|
case 'mousedown':
|
|
@@ -396,6 +401,11 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
396
401
|
this.start1 = this.getTouch(event, 1);
|
|
397
402
|
this.cursor.x = this.start0.x;
|
|
398
403
|
this.cursor.y = this.start0.y;
|
|
404
|
+
this.findEventHandlers(newEvent);
|
|
405
|
+
if (this.currentHandlers.touch) {
|
|
406
|
+
this.cursor.handlerX = this.start0.x - this.currentHandlers.touch.getX();
|
|
407
|
+
this.cursor.handlerY = this.start0.y - this.currentHandlers.touch.getY();
|
|
408
|
+
}
|
|
399
409
|
event.stopPropagation();
|
|
400
410
|
break;
|
|
401
411
|
case 'mousemove':
|
|
@@ -525,6 +535,16 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
525
535
|
value: function cursorY() {
|
|
526
536
|
return this.cursor.y;
|
|
527
537
|
}
|
|
538
|
+
}, {
|
|
539
|
+
key: "swipeX",
|
|
540
|
+
value: function swipeX() {
|
|
541
|
+
return this.cursor.x - this.cursor.handlerX;
|
|
542
|
+
}
|
|
543
|
+
}, {
|
|
544
|
+
key: "swipeY",
|
|
545
|
+
value: function swipeY() {
|
|
546
|
+
return this.cursor.y - this.cursor.handlerY;
|
|
547
|
+
}
|
|
528
548
|
}, {
|
|
529
549
|
key: "pinchDelta",
|
|
530
550
|
value: function pinchDelta() {
|
|
@@ -578,13 +598,28 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
578
598
|
}, {
|
|
579
599
|
key: "isSwipeEvent",
|
|
580
600
|
value: function isSwipeEvent() {
|
|
581
|
-
return
|
|
601
|
+
return this.hasDelta() && this.touchCount === 1;
|
|
602
|
+
}
|
|
603
|
+
}, {
|
|
604
|
+
key: "isScrollEvent",
|
|
605
|
+
value: function isScrollEvent() {
|
|
606
|
+
return this.hasDelta() && this.isCurrentSource('wheel');
|
|
607
|
+
}
|
|
608
|
+
}, {
|
|
609
|
+
key: "hasDelta",
|
|
610
|
+
value: function hasDelta() {
|
|
611
|
+
return this.deltaX() !== 0 || this.deltaY() !== 0;
|
|
582
612
|
}
|
|
583
613
|
}, {
|
|
584
614
|
key: "isEndEvent",
|
|
585
615
|
value: function isEndEvent() {
|
|
586
616
|
return this.getEventType() === 'end';
|
|
587
617
|
}
|
|
618
|
+
}, {
|
|
619
|
+
key: "isStartEvent",
|
|
620
|
+
value: function isStartEvent() {
|
|
621
|
+
return this.getEventType() === 'start';
|
|
622
|
+
}
|
|
588
623
|
}, {
|
|
589
624
|
key: "getEventName",
|
|
590
625
|
value: function getEventName() {
|
|
@@ -757,19 +792,14 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
757
792
|
this.currentTouch.orientation = "horizontal";
|
|
758
793
|
this.currentTouch.dir = deltaX <= -1 ? "left" : deltaX >= 1 ? "right" : this.currentTouch.dir;
|
|
759
794
|
this.currentTouch.source = source;
|
|
760
|
-
this.currentTouch.deltaX = deltaX;
|
|
761
|
-
this.currentTouch.deltaY = 0;
|
|
762
795
|
}
|
|
763
796
|
} else if (this.currentTouch.orientation === "none" || this.currentTouch.orientation === "horizontal" && diff < -3 || this.currentTouch.orientation === "vertical") {
|
|
764
797
|
this.currentTouch.orientation = "vertical";
|
|
765
798
|
this.currentTouch.dir = deltaY <= -1 ? "up" : deltaY >= 1 ? "down" : this.currentTouch.dir;
|
|
766
799
|
this.currentTouch.source = source;
|
|
767
|
-
this.currentTouch.deltaY = deltaY;
|
|
768
|
-
this.currentTouch.deltaX = 0;
|
|
769
|
-
} else {
|
|
770
|
-
this.currentTouch.deltaY = 0;
|
|
771
|
-
this.currentTouch.deltaX = 0;
|
|
772
800
|
}
|
|
801
|
+
this.currentTouch.deltaY = deltaY;
|
|
802
|
+
this.currentTouch.deltaX = deltaX;
|
|
773
803
|
}
|
|
774
804
|
}, {
|
|
775
805
|
key: "wheel",
|
package/build/LocationManager.js
CHANGED
|
@@ -67,19 +67,21 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
67
67
|
var shouldCalculateChildTargets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
68
68
|
var allChildren = this.getChildren(container);
|
|
69
69
|
var viewport = container.createViewport();
|
|
70
|
-
var visibleChildrenCount = container.visibleChildren.length;
|
|
71
70
|
container.visibleChildren.length = 0;
|
|
71
|
+
var visibleChildrenLength = container.visibleChildren.length;
|
|
72
|
+
var childrenLength = container.getChildren().length;
|
|
73
|
+
var length = allChildren.length;
|
|
72
74
|
var i = 0;
|
|
73
|
-
|
|
74
|
-
while (i < childrenLength) {
|
|
75
|
+
while (i < length) {
|
|
75
76
|
var child = allChildren[i++];
|
|
76
77
|
if (!child) {
|
|
77
78
|
continue;
|
|
78
79
|
}
|
|
80
|
+
viewport.setCurrentChild(child);
|
|
81
|
+
viewport.setLocation();
|
|
79
82
|
if (container.manageChildTargetExecution(child, shouldCalculateChildTargets)) {
|
|
80
83
|
this.calculateTargets(child);
|
|
81
84
|
}
|
|
82
|
-
viewport.setCurrentChild(child);
|
|
83
85
|
viewport.setLocation();
|
|
84
86
|
child.overflowingFlag = false;
|
|
85
87
|
if (container.getContainerOverflowMode() === 'always' || child.getItemOverflowMode() === 'always' || container.getContainerOverflowMode() === 'auto' && child.getItemOverflowMode() === 'auto' && viewport.isOverflow()) {
|
|
@@ -89,15 +91,13 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
89
91
|
if (child.isIncluded() && !this.hasLocationMap[child.oid]) {
|
|
90
92
|
this.addToLocationList(child);
|
|
91
93
|
}
|
|
92
|
-
if (child.isTargetEnabled('x') && !child.isTargetUpdating('x') && !child.isTargetImperative('x')
|
|
93
|
-
_TargetExecutor.TargetExecutor.
|
|
94
|
-
_TargetExecutor.TargetExecutor.snapActualToTarget(child, 'x');
|
|
94
|
+
if (child.isTargetEnabled('x') && !child.isTargetUpdating('x') && !child.isTargetImperative('x')) {
|
|
95
|
+
_TargetExecutor.TargetExecutor.executeDeclarativeTarget(child, 'x');
|
|
95
96
|
} else if (!_TUtil.TUtil.isDefined(child.targetValues.x)) {
|
|
96
97
|
child.val('x', child.x);
|
|
97
98
|
}
|
|
98
|
-
if (child.isTargetEnabled('y') && !child.isTargetUpdating('y') && !child.isTargetImperative('y')
|
|
99
|
-
_TargetExecutor.TargetExecutor.
|
|
100
|
-
_TargetExecutor.TargetExecutor.snapActualToTarget(child, 'y');
|
|
99
|
+
if (child.isTargetEnabled('y') && !child.isTargetUpdating('y') && !child.isTargetImperative('y')) {
|
|
100
|
+
_TargetExecutor.TargetExecutor.executeDeclarativeTarget(child, 'y');
|
|
101
101
|
} else if (!_TUtil.TUtil.isDefined(child.targetValues.y)) {
|
|
102
102
|
child.val('y', child.y);
|
|
103
103
|
}
|
|
@@ -142,18 +142,21 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
|
142
142
|
container.calcContentWidthHeight();
|
|
143
143
|
this.locationListStats.push("".concat(child.oid, "-").concat(child.updatingTargetList.length, "-").concat(_TUtil.TUtil.now() - this.startTime));
|
|
144
144
|
}
|
|
145
|
-
if ((
|
|
145
|
+
if ((visibleChildrenLength !== container.visibleChildren.length || container.visibleChildren.length === 0) && container.targets['onVisibleChildrenChange']) {
|
|
146
146
|
this.activateTargets(container, container.targets['onVisibleChildrenChange']);
|
|
147
147
|
}
|
|
148
|
+
if (childrenLength !== container.getChildren().length && container.targets['onChildrenChange']) {
|
|
149
|
+
this.activateTargets(container, container.targets['onChildrenChange']);
|
|
150
|
+
}
|
|
148
151
|
}
|
|
149
152
|
}, {
|
|
150
153
|
key: "calculateTargets",
|
|
151
154
|
value: function calculateTargets(tmodel) {
|
|
152
|
-
var
|
|
155
|
+
var childrenLength = tmodel.getChildren().length;
|
|
153
156
|
this.activateTargetsOnEvents(tmodel);
|
|
154
157
|
_App.tApp.targetManager.applyTargetValues(tmodel);
|
|
155
158
|
_App.tApp.targetManager.setActualValues(tmodel);
|
|
156
|
-
if (
|
|
159
|
+
if (tmodel.getChildren().length === 0 && childrenLength > 0 && tmodel.targets['onChildrenChange']) {
|
|
157
160
|
this.activateTargets(tmodel, tmodel.targets['onChildrenChange']);
|
|
158
161
|
}
|
|
159
162
|
if (tmodel.hasDom()) {
|
package/build/SearchUtil.js
CHANGED
|
@@ -30,19 +30,32 @@ var SearchUtil = exports.SearchUtil = /*#__PURE__*/function () {
|
|
|
30
30
|
}
|
|
31
31
|
}, {
|
|
32
32
|
key: "findFirstScrollTopHandler",
|
|
33
|
-
value: function findFirstScrollTopHandler(tmodel) {
|
|
34
|
-
return SearchUtil.
|
|
33
|
+
value: function findFirstScrollTopHandler(tmodel, eventType) {
|
|
34
|
+
return SearchUtil.findScrollHandler(tmodel, eventType, 'scrollTop');
|
|
35
35
|
}
|
|
36
36
|
}, {
|
|
37
37
|
key: "findFirstScrollLeftHandler",
|
|
38
|
-
value: function findFirstScrollLeftHandler(tmodel) {
|
|
39
|
-
return SearchUtil.
|
|
38
|
+
value: function findFirstScrollLeftHandler(tmodel, eventType) {
|
|
39
|
+
return SearchUtil.findScrollHandler(tmodel, eventType, 'scrollLeft');
|
|
40
40
|
}
|
|
41
41
|
}, {
|
|
42
42
|
key: "findFirstTouchHandler",
|
|
43
43
|
value: function findFirstTouchHandler(tmodel) {
|
|
44
44
|
return SearchUtil.findEventHandler(tmodel, 'touch');
|
|
45
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "findScrollHandler",
|
|
48
|
+
value: function findScrollHandler(tmodel, eventType, eventName) {
|
|
49
|
+
while (tmodel) {
|
|
50
|
+
if (tmodel.canHandleEvents('swipe') && eventType !== 'wheel') {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (tmodel.canHandleEvents(eventName)) {
|
|
54
|
+
return tmodel;
|
|
55
|
+
}
|
|
56
|
+
tmodel = tmodel.getParent();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
46
59
|
}, {
|
|
47
60
|
key: "findEventHandler",
|
|
48
61
|
value: function findEventHandler(tmodel, eventName) {
|
package/build/TModel.js
CHANGED
|
@@ -127,40 +127,21 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
127
127
|
return this;
|
|
128
128
|
}
|
|
129
129
|
}, {
|
|
130
|
-
key: "
|
|
131
|
-
value: function
|
|
132
|
-
this.allChildren.
|
|
133
|
-
this.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//we need to use the parent so in case there is a bracket, the child will be added to the real parent
|
|
140
|
-
}, {
|
|
141
|
-
key: "addToParentVisibleChildren",
|
|
142
|
-
value: function addToParentVisibleChildren() {
|
|
143
|
-
if (this.isVisible() && this.isInFlow() && this.getParent()) {
|
|
144
|
-
this.getParent().visibleChildren.push(this);
|
|
130
|
+
key: "moveChildTo",
|
|
131
|
+
value: function moveChildTo(child, toIndex) {
|
|
132
|
+
var newArray = this.allChildren.slice(0);
|
|
133
|
+
var fromIndex = this.allChildren.indexOf(child);
|
|
134
|
+
if (fromIndex === -1 || toIndex < 0 || toIndex > newArray.length) {
|
|
135
|
+
return;
|
|
145
136
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this.actualValues.calculateChildren;
|
|
137
|
+
newArray.splice(fromIndex, 1);
|
|
138
|
+
if (toIndex === newArray.length) {
|
|
139
|
+
newArray.push(child);
|
|
140
|
+
} else {
|
|
141
|
+
newArray.splice(toIndex, 0, child);
|
|
152
142
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}, {
|
|
156
|
-
key: "getFirstChild",
|
|
157
|
-
value: function getFirstChild() {
|
|
158
|
-
return this.hasChildren() ? this.getChildren()[0] : undefined;
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "hasChildren",
|
|
162
|
-
value: function hasChildren() {
|
|
163
|
-
return this.getChildren().length > 0;
|
|
143
|
+
this.allChildren = newArray;
|
|
144
|
+
(0, _App.getRunScheduler)().schedule(10, "addChild-".concat(this.oid, "-").concat(child.oid));
|
|
164
145
|
}
|
|
165
146
|
}, {
|
|
166
147
|
key: "getChildren",
|
|
@@ -197,6 +178,49 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
197
178
|
}
|
|
198
179
|
return this.allChildren;
|
|
199
180
|
}
|
|
181
|
+
}, {
|
|
182
|
+
key: "removeAllChildren",
|
|
183
|
+
value: function removeAllChildren() {
|
|
184
|
+
this.allChildren.length = 0;
|
|
185
|
+
this.updatingChildrenList.length = 0;
|
|
186
|
+
this.updatingChildrenMap = {};
|
|
187
|
+
(0, _App.getRunScheduler)().schedule(10, 'removeAllChildren-' + this.oid);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//we need to use the parent so in case there is a bracket, the child will be added to the real parent
|
|
192
|
+
}, {
|
|
193
|
+
key: "addToParentVisibleChildren",
|
|
194
|
+
value: function addToParentVisibleChildren() {
|
|
195
|
+
if (this.isVisible() && this.isInFlow() && this.getParent()) {
|
|
196
|
+
this.getParent().visibleChildren.push(this);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}, {
|
|
200
|
+
key: "shouldCalculateChildren",
|
|
201
|
+
value: function shouldCalculateChildren() {
|
|
202
|
+
if (_TUtil.TUtil.isDefined(this.actualValues.calculateChildren)) {
|
|
203
|
+
return this.actualValues.calculateChildren;
|
|
204
|
+
}
|
|
205
|
+
return this.isVisible() && this.isIncluded() && (this.hasChildren() || this.addedChildren.count > 0 || this.getContentHeight() > 0);
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "getFirstChild",
|
|
209
|
+
value: function getFirstChild() {
|
|
210
|
+
return this.hasChildren() ? this.getChildren()[0] : undefined;
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "hasChildren",
|
|
214
|
+
value: function hasChildren() {
|
|
215
|
+
return this.getChildren().length > 0;
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "findChildren",
|
|
219
|
+
value: function findChildren(type) {
|
|
220
|
+
return this.getChildren().filter(function (child) {
|
|
221
|
+
return child.type === type;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
200
224
|
}, {
|
|
201
225
|
key: "getLastChild",
|
|
202
226
|
value: function getLastChild() {
|
package/build/TargetUtil.js
CHANGED
|
@@ -427,13 +427,19 @@ _defineProperty(TargetUtil, "targetConditionMap", {
|
|
|
427
427
|
onClickEvent: function onClickEvent(tmodel) {
|
|
428
428
|
return (0, _App.getEvents)().getEventType() === 'click' && (0, _App.getEvents)().isClickHandler(tmodel);
|
|
429
429
|
},
|
|
430
|
+
onTouchStart: function onTouchStart(tmodel) {
|
|
431
|
+
return (0, _App.getEvents)().isStartEvent() && (0, _App.getEvents)().isTouchHandler(tmodel);
|
|
432
|
+
},
|
|
430
433
|
onTouchEnd: function onTouchEnd() {
|
|
431
434
|
return (0, _App.getEvents)().isEndEvent();
|
|
432
435
|
},
|
|
433
436
|
onKeyEvent: function onKeyEvent() {
|
|
434
437
|
return (0, _App.getEvents)().getEventType() === 'key' && (0, _App.getEvents)().currentKey;
|
|
435
438
|
},
|
|
436
|
-
onSwipeEvent: function onSwipeEvent() {
|
|
439
|
+
onSwipeEvent: function onSwipeEvent(tmodel) {
|
|
440
|
+
return (0, _App.getEvents)().isTouchHandler(tmodel) && (0, _App.getEvents)().isSwipeEvent();
|
|
441
|
+
},
|
|
442
|
+
onAnySwipeEvent: function onAnySwipeEvent() {
|
|
437
443
|
return (0, _App.getEvents)().isSwipeEvent();
|
|
438
444
|
},
|
|
439
445
|
onTouchEvent: function onTouchEvent(tmodel) {
|
package/build/Viewport.js
CHANGED
|
@@ -60,7 +60,7 @@ var Viewport = exports.Viewport = /*#__PURE__*/function () {
|
|
|
60
60
|
key: "appendNewLine",
|
|
61
61
|
value: function appendNewLine() {
|
|
62
62
|
var height = this.currentChild.getHeight() * this.currentChild.getMeasuringScale();
|
|
63
|
-
this.xNext = this.xOverflowReset;
|
|
63
|
+
this.xNext = this.scrollLeft - this.absX + this.xOverflowReset;
|
|
64
64
|
this.yNext = this.ySouth > this.yNext ? this.ySouth + this.currentChild.val('appendNewLine') : this.ySouth + height + this.currentChild.val('appendNewLine');
|
|
65
65
|
this.yEast = this.yNext;
|
|
66
66
|
this.xSouth = this.xNext;
|