targetj 1.0.260 → 1.1.1
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 +3 -0
- package/build/AnimationManager.js +221 -153
- package/build/AnimationUtil.js +0 -1
- package/build/App.js +82 -34
- package/build/BaseModel.js +51 -15
- package/build/Bracket.js +7 -1
- package/build/Easing.js +5 -0
- package/build/EventListener.js +37 -8
- package/build/HtmlToCanvas.js +411 -0
- package/build/LocationManager.js +167 -46
- package/build/PageManager.js +67 -115
- package/build/ParticleChild.js +576 -0
- package/build/ParticleExplode.js +360 -0
- package/build/ParticleRenderer.js +821 -159
- package/build/ParticleRuntime.js +1529 -381
- package/build/ParticleTModel.js +864 -293
- package/build/ParticleUtil.js +120 -172
- package/build/RunScheduler.js +23 -11
- package/build/StateManager.js +206 -57
- package/build/StateUtil.js +141 -82
- package/build/TModel.js +172 -73
- package/build/TModelManager.js +155 -132
- package/build/TModelUtil.js +232 -142
- package/build/TUtil.js +55 -50
- package/build/TargetData.js +26 -12
- package/build/TargetExecutor.js +48 -17
- package/build/TargetManager.js +47 -39
- package/build/TargetParser.js +57 -4
- package/build/TargetUtil.js +211 -129
- package/build/VisibilityUtil.js +4 -2
- package/build/index.js +1 -0
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/build/TargetManager.js
CHANGED
|
@@ -77,7 +77,7 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
77
77
|
tmodel.resetScheduleTimeStamp(key);
|
|
78
78
|
TargetExecutor.prepareTarget(tmodel, key);
|
|
79
79
|
TargetExecutor.executeDeclarativeTarget(tmodel, key);
|
|
80
|
-
if (!
|
|
80
|
+
if (!TargetUtil.hasFetchAction(tmodel, key)) {
|
|
81
81
|
TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -99,7 +99,7 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
99
99
|
}
|
|
100
100
|
schedulePeriod = ScheduleUtil.scheduleExecution(tmodel, key);
|
|
101
101
|
if (schedulePeriod > 0) {
|
|
102
|
-
getRunScheduler().
|
|
102
|
+
getRunScheduler().scheduleOnlyIfEarlier(schedulePeriod, "setActualValues-".concat(tmodel.oid, "-").concat(key));
|
|
103
103
|
} else {
|
|
104
104
|
tmodel.resetScheduleTimeStamp(key);
|
|
105
105
|
this.setActualValue(tmodel, key);
|
|
@@ -225,30 +225,20 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
225
225
|
}, {
|
|
226
226
|
key: "calculateTargetStatus",
|
|
227
227
|
value: function calculateTargetStatus(tmodel, key) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return;
|
|
228
|
+
if (TargetUtil.isTargetUpdating(tmodel, key)) {
|
|
229
|
+
return 'updating';
|
|
231
230
|
}
|
|
232
|
-
var valuePointer = tmodel.getValueListPointer(key);
|
|
233
231
|
var cycle = tmodel.getTargetCycle(key);
|
|
234
232
|
var cycles = tmodel.getTargetCycles(key);
|
|
235
|
-
|
|
236
|
-
var steps = tmodel.getTargetSteps(key);
|
|
237
|
-
if (Array.isArray(targetValue.valueList) && valuePointer < targetValue.valueList.length) {
|
|
238
|
-
return 'updating';
|
|
239
|
-
} else if (tmodel.isTargetImperative(key) && cycle < cycles - 1) {
|
|
240
|
-
return 'updating';
|
|
241
|
-
} else if (step < steps) {
|
|
242
|
-
return 'updating';
|
|
243
|
-
} else if (tmodel.isTargetInLoop(key) || cycle < cycles - 1) {
|
|
233
|
+
if (tmodel.isTargetInLoop(key) || cycle < cycles - 1) {
|
|
244
234
|
return 'active';
|
|
245
|
-
} else {
|
|
246
|
-
return 'done';
|
|
247
235
|
}
|
|
236
|
+
return 'done';
|
|
248
237
|
}
|
|
249
238
|
}, {
|
|
250
239
|
key: "catchupTargetByElapsed",
|
|
251
240
|
value: function catchupTargetByElapsed(tmodel, key) {
|
|
241
|
+
var _targetValue$valueLis4;
|
|
252
242
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
253
243
|
_ref$fireEnd = _ref.fireEnd,
|
|
254
244
|
fireEnd = _ref$fireEnd === void 0 ? false : _ref$fireEnd;
|
|
@@ -262,17 +252,16 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
262
252
|
var step = progress.step;
|
|
263
253
|
var valuePointer = progress.valuePointer;
|
|
264
254
|
var cycle = progress.cycle;
|
|
265
|
-
var theValue = tmodel.getTargetValue(key);
|
|
266
|
-
var steps = tmodel.getTargetSteps(key);
|
|
267
255
|
var cycles = tmodel.getTargetCycles(key);
|
|
268
256
|
if (progress.done) {
|
|
269
|
-
var _targetValue$valueLis, _targetValue$valueLis2, _targetValue$valueLis3;
|
|
270
|
-
var finalValue = (_targetValue$valueLis = targetValue.valueList) !== null && _targetValue$valueLis !== void 0 && _targetValue$valueLis.length ? targetValue.valueList[targetValue.valueList.length - 1] :
|
|
257
|
+
var _targetValue$valueLis, _progress$steps, _targetValue$valueLis2, _targetValue$valueLis3;
|
|
258
|
+
var finalValue = (_targetValue$valueLis = targetValue.valueList) !== null && _targetValue$valueLis !== void 0 && _targetValue$valueLis.length ? targetValue.valueList[targetValue.valueList.length - 1] : tmodel.getTargetValue(key);
|
|
271
259
|
tmodel.val(key, finalValue);
|
|
272
260
|
tmodel.setActual(key, finalValue);
|
|
273
261
|
tmodel.addToStyleTargetList(key);
|
|
274
|
-
targetValue.step = steps;
|
|
262
|
+
targetValue.step = (_progress$steps = progress.steps) !== null && _progress$steps !== void 0 ? _progress$steps : tmodel.getTargetSteps(key);
|
|
275
263
|
targetValue.valuePointer = (_targetValue$valueLis2 = (_targetValue$valueLis3 = targetValue.valueList) === null || _targetValue$valueLis3 === void 0 ? void 0 : _targetValue$valueLis3.length) !== null && _targetValue$valueLis2 !== void 0 ? _targetValue$valueLis2 : valuePointer;
|
|
264
|
+
targetValue.value = finalValue;
|
|
276
265
|
targetValue.cycle = cycles;
|
|
277
266
|
delete targetValue.catchupAt;
|
|
278
267
|
if (fireEnd) {
|
|
@@ -280,11 +269,23 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
280
269
|
}
|
|
281
270
|
return {
|
|
282
271
|
done: true,
|
|
283
|
-
step:
|
|
272
|
+
step: targetValue.step,
|
|
284
273
|
cycle: cycles,
|
|
285
274
|
valuePointer: targetValue.valuePointer
|
|
286
275
|
};
|
|
287
276
|
}
|
|
277
|
+
if ((_targetValue$valueLis4 = targetValue.valueList) !== null && _targetValue$valueLis4 !== void 0 && _targetValue$valueLis4.length) {
|
|
278
|
+
targetValue.valuePointer = valuePointer;
|
|
279
|
+
targetValue.initialValue = targetValue.valueList[valuePointer - 1];
|
|
280
|
+
targetValue.value = targetValue.valueList[valuePointer];
|
|
281
|
+
targetValue.steps = targetValue.stepList[(valuePointer - 1) % targetValue.stepList.length];
|
|
282
|
+
targetValue.interval = Array.isArray(targetValue.intervalList) ? targetValue.intervalList[(valuePointer - 1) % targetValue.intervalList.length] : targetValue.interval;
|
|
283
|
+
targetValue.easing = targetValue.easingList[(valuePointer - 1) % targetValue.easingList.length];
|
|
284
|
+
}
|
|
285
|
+
targetValue.step = step;
|
|
286
|
+
targetValue.cycle = cycle;
|
|
287
|
+
var theValue = tmodel.getTargetValue(key);
|
|
288
|
+
var steps = tmodel.getTargetSteps(key);
|
|
288
289
|
var initialValue = tmodel.getTargetInitialValue(key);
|
|
289
290
|
if (!TUtil.isDefined(initialValue)) {
|
|
290
291
|
initialValue = this.resolveInitialValue(tmodel, key, theValue);
|
|
@@ -294,9 +295,6 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
294
295
|
tmodel.val(key, value);
|
|
295
296
|
tmodel.setActual(key, value);
|
|
296
297
|
tmodel.addToStyleTargetList(key);
|
|
297
|
-
targetValue.step = step;
|
|
298
|
-
targetValue.valuePointer = valuePointer;
|
|
299
|
-
targetValue.cycle = cycle;
|
|
300
298
|
return {
|
|
301
299
|
done: false,
|
|
302
300
|
step: step,
|
|
@@ -332,7 +330,7 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
332
330
|
if (tmodel.canBeAnimated(state.cleanKey)) {
|
|
333
331
|
this.animateActualValue(tmodel, key, targetValue, state, step, valuePointer);
|
|
334
332
|
} else {
|
|
335
|
-
this.updateActualValue(tmodel, key, targetValue, state, step
|
|
333
|
+
this.updateActualValue(tmodel, key, targetValue, state, step);
|
|
336
334
|
}
|
|
337
335
|
}
|
|
338
336
|
}, {
|
|
@@ -372,20 +370,26 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
372
370
|
}, {
|
|
373
371
|
key: "animateActualValue",
|
|
374
372
|
value: function animateActualValue(tmodel, key, targetValue, state, step, valuePointer) {
|
|
373
|
+
var _targetValue$valueLis5;
|
|
375
374
|
if (!tmodel.hasDom()) {
|
|
376
375
|
tmodel.addToNoDomUpdatingTargets(key);
|
|
377
376
|
return;
|
|
378
377
|
}
|
|
379
378
|
var newValue = step > 0 ? TModelUtil.easingMorph(tmodel, key, state.initialValue, state.theValue, step, state.steps) : state.initialValue;
|
|
380
|
-
var cycles = tmodel.isTargetImperative(key) ? tmodel.getTargetCycles(key) : 0;
|
|
381
379
|
var cycleDuration = AnimationUtil.handleWebAnimationAPI(tmodel, state.cleanKey, key, targetValue, newValue, state.theValue, valuePointer, step, state.steps, state.interval, 0, false, true);
|
|
380
|
+
|
|
381
|
+
// AnimationUtil already expands all cycles for value lists.
|
|
382
|
+
if ((_targetValue$valueLis5 = targetValue.valueList) !== null && _targetValue$valueLis5 !== void 0 && _targetValue$valueLis5.length) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
var cycles = tmodel.isTargetImperative(key) ? tmodel.getTargetCycles(key) : 1;
|
|
382
386
|
for (var c = 1; c < cycles; c++) {
|
|
383
387
|
AnimationUtil.handleWebAnimationAPI(tmodel, state.cleanKey, key, targetValue, newValue, state.theValue, valuePointer, step, state.steps, state.interval, c * cycleDuration, true, false);
|
|
384
388
|
}
|
|
385
389
|
}
|
|
386
390
|
}, {
|
|
387
391
|
key: "updateActualValue",
|
|
388
|
-
value: function updateActualValue(tmodel, key, targetValue, state, step
|
|
392
|
+
value: function updateActualValue(tmodel, key, targetValue, state, step) {
|
|
389
393
|
if (step <= state.steps) {
|
|
390
394
|
tmodel.incrementTargetStep(key, state.now, state.lastUpdateTime, state.interval, state.steps);
|
|
391
395
|
var newValue = TModelUtil.easingMorph(tmodel, key, state.initialValue, state.theValue, step, state.steps);
|
|
@@ -398,27 +402,31 @@ var TargetManager = /*#__PURE__*/function () {
|
|
|
398
402
|
return;
|
|
399
403
|
}
|
|
400
404
|
}
|
|
401
|
-
this.finishCurrentSegment(tmodel, key, targetValue, state
|
|
405
|
+
this.finishCurrentSegment(tmodel, key, targetValue, state);
|
|
402
406
|
}
|
|
403
407
|
}, {
|
|
404
408
|
key: "finishCurrentSegment",
|
|
405
|
-
value: function finishCurrentSegment(tmodel, key, targetValue, state
|
|
409
|
+
value: function finishCurrentSegment(tmodel, key, targetValue, state) {
|
|
406
410
|
tmodel.val(key, state.theValue);
|
|
407
411
|
tmodel.setActual(key, state.theValue);
|
|
408
412
|
tmodel.addToStyleTargetList(key);
|
|
409
413
|
targetValue.step = state.steps;
|
|
410
414
|
tmodel.setLastUpdate(key);
|
|
411
415
|
var scheduleTime = 1;
|
|
412
|
-
if (targetValue.valueList
|
|
416
|
+
if (targetValue.valueList) {
|
|
413
417
|
tmodel.incrementValueListPointer(key);
|
|
414
418
|
var nextPointer = tmodel.getValueListPointer(key);
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
if (nextPointer < targetValue.valueList.length) {
|
|
420
|
+
tmodel.resetTargetStep(key);
|
|
421
|
+
targetValue.initialValue = targetValue.value;
|
|
422
|
+
targetValue.value = targetValue.valueList[nextPointer];
|
|
423
|
+
targetValue.steps = targetValue.stepList[(nextPointer - 1) % targetValue.stepList.length];
|
|
424
|
+
targetValue.interval = Array.isArray(targetValue.intervalList) ? targetValue.intervalList[(nextPointer - 1) % targetValue.intervalList.length] : 0;
|
|
425
|
+
targetValue.easing = targetValue.easingList[(nextPointer - 1) % targetValue.easingList.length];
|
|
426
|
+
scheduleTime = state.interval;
|
|
427
|
+
} else {
|
|
428
|
+
this.fireOnEnd(tmodel, key);
|
|
429
|
+
}
|
|
422
430
|
} else {
|
|
423
431
|
this.fireOnEnd(tmodel, key);
|
|
424
432
|
}
|
package/build/TargetParser.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
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; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1
7
|
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); }
|
|
2
8
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
3
9
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
@@ -9,6 +15,7 @@ import { TargetData } from './TargetData.js';
|
|
|
9
15
|
import { TUtil } from './TUtil.js';
|
|
10
16
|
import { TModel } from "./TModel.js";
|
|
11
17
|
import { Easing } from "./Easing.js";
|
|
18
|
+
import { getEvents } from "./App.js";
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* It provides helper functions for classify target types
|
|
@@ -26,8 +33,11 @@ var TargetParser = /*#__PURE__*/function () {
|
|
|
26
33
|
key: "hasLifecycle",
|
|
27
34
|
value: function hasLifecycle(object) {
|
|
28
35
|
for (var key in object) {
|
|
29
|
-
|
|
30
|
-
if (
|
|
36
|
+
// Event handlers are not target lifecycle callbacks.
|
|
37
|
+
if (TargetData.eventSet.has(key)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (typeof object[key] === 'function' && TargetData.isLifeCycleMethod(key)) {
|
|
31
41
|
return true;
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -114,7 +124,25 @@ var TargetParser = /*#__PURE__*/function () {
|
|
|
114
124
|
}, {
|
|
115
125
|
key: "getInstanceTargetValue",
|
|
116
126
|
value: function getInstanceTargetValue(tmodel, key, target, cycle, lastValue, instance) {
|
|
117
|
-
return
|
|
127
|
+
return TargetParser.runTargetValue(tmodel, target, key, cycle, lastValue, instance);
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "runTargetValue",
|
|
131
|
+
value: function runTargetValue(tmodel, target, key, cycle, lastValue) {
|
|
132
|
+
var instance = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
|
|
133
|
+
var cleanKey = TargetUtil.getTargetName(key);
|
|
134
|
+
var isExternalEvent = TargetData.allEventMap[cleanKey];
|
|
135
|
+
var instanceArgs = TUtil.isDefined(instance) ? [instance] : [];
|
|
136
|
+
if (isExternalEvent) {
|
|
137
|
+
var _target$value;
|
|
138
|
+
return typeof target.value === 'function' ? (_target$value = target.value).call.apply(_target$value, [tmodel].concat(instanceArgs, [getEvents().getCurrentOriginalEvent(), cycle, lastValue])) : TUtil.isDefined(target.value) ? target.value : target;
|
|
139
|
+
} else if (tmodel.val("___".concat(key))) {
|
|
140
|
+
var _target$value2;
|
|
141
|
+
return typeof target.value === 'function' ? (_target$value2 = target.value).call.apply(_target$value2, [tmodel].concat(instanceArgs, [tmodel.val("___".concat(key)), cycle, lastValue])) : TUtil.isDefined(target.value) ? target.value : target;
|
|
142
|
+
} else {
|
|
143
|
+
var _target$value3;
|
|
144
|
+
return typeof target.value === 'function' ? (_target$value3 = target.value).call.apply(_target$value3, [tmodel].concat(instanceArgs, [cycle, lastValue])) : TUtil.isDefined(target.value) ? target.value : target;
|
|
145
|
+
}
|
|
118
146
|
}
|
|
119
147
|
}, {
|
|
120
148
|
key: "isChildrenTarget",
|
|
@@ -273,7 +301,7 @@ var TargetParser = /*#__PURE__*/function () {
|
|
|
273
301
|
|
|
274
302
|
// Plain objects: compute value + params (steps/interval/easing/cycles)
|
|
275
303
|
if (_typeof(target) === "object" && target !== null && Object.getPrototypeOf(target) === Object.prototype) {
|
|
276
|
-
var valueResult =
|
|
304
|
+
var valueResult = TargetParser.runTargetValue(tmodel, target, key, cycle, lastValue, instance);
|
|
277
305
|
if (TargetParser.isPrimitiveArray(valueResult) && (TUtil.isDefined(target.steps) || TUtil.isDefined(target.interval) || TUtil.isDefined(target.easing) || TUtil.isDefined(target.cycles))) {
|
|
278
306
|
value = {
|
|
279
307
|
list: valueResult
|
|
@@ -305,6 +333,31 @@ var TargetParser = /*#__PURE__*/function () {
|
|
|
305
333
|
}
|
|
306
334
|
return getValue(_target);
|
|
307
335
|
}
|
|
336
|
+
}, {
|
|
337
|
+
key: "getInitialTargetValue",
|
|
338
|
+
value: function getInitialTargetValue(tmodel, key, target) {
|
|
339
|
+
var cycle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
340
|
+
if (typeof target === "function") {
|
|
341
|
+
return TargetParser.getInitialTargetValue(tmodel, key, target.call(tmodel, cycle, tmodel.val(key)), cycle);
|
|
342
|
+
}
|
|
343
|
+
if (TargetParser.isPlainObject(target)) {
|
|
344
|
+
if (TUtil.isDefined(target.initialValue)) {
|
|
345
|
+
return TargetParser.getInitialTargetValue(tmodel, key, target.initialValue, cycle);
|
|
346
|
+
}
|
|
347
|
+
if (typeof target.value === "function") {
|
|
348
|
+
return TargetParser.getInitialTargetValue(tmodel, key, target.value.call(tmodel, cycle, tmodel.val(key)), cycle);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
var _TargetParser$getValu = TargetParser.getValueStepsCycles(tmodel, key, target, cycle),
|
|
352
|
+
_TargetParser$getValu2 = _slicedToArray(_TargetParser$getValu, 1),
|
|
353
|
+
value = _TargetParser$getValu2[0];
|
|
354
|
+
return TargetParser.isListTarget(value) ? value.list[0] : value;
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "isExplodeChildrenTarget",
|
|
358
|
+
value: function isExplodeChildrenTarget(key) {
|
|
359
|
+
return TargetUtil.getTargetName(key) === "explodeChildren";
|
|
360
|
+
}
|
|
308
361
|
}]);
|
|
309
362
|
}();
|
|
310
363
|
export { TargetParser };
|