targetj 1.0.153 → 1.0.154

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 CHANGED
@@ -83,7 +83,7 @@ npm install targetj
83
83
  - Targets run initially in the order they appear in the code, so `background` runs first, followed by `width`. The `_` prefix indicates that a target is inactive by default, meaning `height` does not run initially.
84
84
  - `background` sets the background to purple, and its lifecycle ends.
85
85
  - `width` animates from 100 → 250 → 100px, in 50 steps with 10ms pauses.
86
- - `height` follows `width` and scales dynamically with its value. The `$` postfix means it is activated each time the proceding target executes. `prevTargetValue` refers to the previous target's value, which in this case is `width`.
86
+ - `height` follows `width` and scales dynamically with its value. The `$` postfix means it is activated each time the preceding target executes. `prevTargetValue` refers to the previous target's value, which in this case is `width`.
87
87
 
88
88
  ![first example](https://targetjs.io/img/quick1_3.gif)
89
89
 
@@ -407,26 +407,25 @@ If you inspect the HTML elements in the browser's developer tools, you'll notice
407
407
  ![Single page app](https://targetjs.io/img/infiniteScrolling11.gif)
408
408
 
409
409
  ```bash
410
- import { App, TModel, getEvents, getLoader, getScreenWidth, getScreenHeight } from "targetj";
410
+ import { App, getEvents, getLoader, getScreenWidth, getScreenHeight } from "targetj";
411
411
 
412
412
  App({
413
413
  containerOverflowMode: "always",
414
414
  children() {
415
415
  const childrenCount = this.getChildren().length;
416
- return Array.from({ length: 20 }, (_, i) =>
417
- new TModel("scrollItem", {
418
- width: [{list: [100, 250]}, 15],
419
- background: [{list: ["#FCE961", "#B388FF"]}, 15, 15],
420
- height: 48,
421
- color: "#C2FC61",
422
- textAlign: "center",
423
- lineHeight: 48,
424
- bottomMargin: 2,
425
- x() { return this.getCenterX(); },
426
- validateVisibilityInParent: true,
427
- html: childrenCount + i
428
- })
429
- );
416
+ return Array.from({ length: 20 }, (_, i) => ({
417
+ id: 'scrollItem',
418
+ width: [{list: [100, 250]}, 15],
419
+ background: [{list: ["#FCE961", "#B388FF"]}, 15, 15],
420
+ height: 48,
421
+ color: "#C2FC61",
422
+ textAlign: "center",
423
+ lineHeight: 48,
424
+ bottomMargin: 2,
425
+ x() { return this.getCenterX(); },
426
+ validateVisibilityInParent: true,
427
+ html: childrenCount + i
428
+ }));
430
429
  },
431
430
  _load$() {
432
431
  this.prevTargetValue.forEach(data =>
@@ -274,7 +274,14 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
274
274
  var target = tmodel.targets[targetName];
275
275
  if (tmodel.isTargetEnabled(targetName)) {
276
276
  if (typeof target.value === 'function') {
277
- target.value.call(tmodel, originalEventTarget);
277
+ var result = target.value.call(tmodel, originalEventTarget);
278
+ if (Array.isArray(result)) {
279
+ result.forEach(function (t) {
280
+ return _TargetUtil.TargetUtil.activateSingleTarget(tmodel, t);
281
+ });
282
+ } else if (typeof result === 'string') {
283
+ _TargetUtil.TargetUtil.activateSingleTarget(tmodel, result);
284
+ }
278
285
  } else if (Array.isArray(target.value)) {
279
286
  target.value.forEach(function (t) {
280
287
  return _TargetUtil.TargetUtil.activateSingleTarget(tmodel, t);
@@ -111,6 +111,7 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
111
111
  var doesNextTargetUsePrevValue = nextKey && nextKey.endsWith('$') ? true : false;
112
112
  target.originalTargetName = TargetUtil.currentTargetName;
113
113
  target.originalTModel = TargetUtil.currentTModel;
114
+ var cleanKey = TargetUtil.getTargetName(key);
114
115
  if (doesNextTargetUsePrevValue) {
115
116
  target.activateNextTarget = nextKey.slice(0, -1);
116
117
  }
@@ -118,19 +119,32 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
118
119
  var endPattern = /^on[A-Za-z]+End$/;
119
120
  var methods = ['value', 'enabledOn', 'onStepsEnd', 'onValueChange', 'loop', 'onImperativeEnd', 'onImperativeStep', 'onSuccess', 'onError'];
120
121
  Object.keys(target).forEach(function (method) {
121
- if (typeof target[method] === 'function' && (methods.includes(method) || stepPattern.test(method) || endPattern.test(method))) {
122
+ if (method === 'value') {
122
123
  var originalMethod = target[method];
123
124
  target[method] = function () {
124
125
  var _getPrevUpdateTime;
125
- TargetUtil.currentTargetName = TargetUtil.getTargetName(key);
126
+ TargetUtil.currentTargetName = cleanKey;
126
127
  TargetUtil.currentTModel = tmodel;
127
- this.key = TargetUtil.getTargetName(key);
128
+ this.key = cleanKey;
128
129
  this.prevTargetValue = getPrevValue();
129
130
  this.isPrevTargetUpdated = isPrevTargetUpdated;
130
- var result = originalMethod.apply(this, arguments);
131
+ var result = typeof originalMethod === 'function' ? originalMethod.apply(this, arguments) : originalMethod;
131
132
  lastPrevUpdateTime = (_getPrevUpdateTime = getPrevUpdateTime()) !== null && _getPrevUpdateTime !== void 0 ? _getPrevUpdateTime : lastPrevUpdateTime;
132
133
  return result;
133
134
  };
135
+ } else if (typeof target[method] === 'function' && (methods.includes(method) || stepPattern.test(method) || endPattern.test(method))) {
136
+ var _originalMethod = target[method];
137
+ target[method] = function () {
138
+ var _getPrevUpdateTime2;
139
+ TargetUtil.currentTargetName = cleanKey;
140
+ TargetUtil.currentTModel = tmodel;
141
+ this.key = cleanKey;
142
+ this.prevTargetValue = getPrevValue();
143
+ this.isPrevTargetUpdated = isPrevTargetUpdated;
144
+ var result = typeof _originalMethod === 'function' ? _originalMethod.apply(this, arguments) : _originalMethod;
145
+ lastPrevUpdateTime = (_getPrevUpdateTime2 = getPrevUpdateTime()) !== null && _getPrevUpdateTime2 !== void 0 ? _getPrevUpdateTime2 : lastPrevUpdateTime;
146
+ return result;
147
+ };
134
148
  }
135
149
  });
136
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.153",
3
+ "version": "1.0.154",
4
4
  "keywords": [
5
5
  "targetjs"
6
6
  ],