targetj 1.0.120 → 1.0.122

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
@@ -1,6 +1,6 @@
1
- # TargetJ: JavaScript UI framework Redefining Front-End Development
1
+ # TargetJ: JavaScript UI framework and library
2
2
 
3
- Welcome to TargetJ, a powerful JavaScript UI framework designed to simplify development and animation. (https://targetj.io)
3
+ Welcome to TargetJ, a powerful JavaScript UI framework and library designed to simplify development and animation, and you might find that it redefines front-end development. (https://targetj.io)
4
4
 
5
5
  TargetJ distinguishes itself by introducing a novel concept known as 'targets', which forms its core. Targets are used as the main building blocks of components instead of direct variables and methods. Each component in TargetJ is a set of targets. Targets are employed across all aspects of the program. They are used in animation, controlling program flow, loading data from external APIs, handling user events, and more.
6
6
 
@@ -16,6 +16,9 @@ npm install targetj
16
16
 
17
17
  Imagine building a single-page web app using a unified approach for API integration, animations, event handling, and more—without having to manage asynchronous calls, loops, callbacks, promises, timeouts, state management, CSS, HTML attributes, tags, or HTML nesting. That’s exactly what TargetJ offers: it simplifies the entire development process with a new, simplified paradigm.
18
18
 
19
+ ## Can I integrate TargetJ as a library into my existing page?
20
+ Yes, you can integrate TargetJ as a library into your existing page! TargetJ is designed to be flexible and works seamlessly with other libraries and frameworks, allowing you to enhance your page with minimal changes. You can find an example at the end of this page.
21
+
19
22
  ## What are targets?
20
23
 
21
24
  Targets provide a unified interface for variable assignments and methods, giving them life cycles and the autonomy to operate independently, with various callbacks to adapt to changes, mimicking the behavior of living cells.
@@ -447,6 +450,44 @@ App(new TModel("simpleApp", {
447
450
  }));
448
451
  ```
449
452
 
453
+ ## Using TargetJ as a library into your page
454
+
455
+ Here is an example that creates 1000 rows. The first argument, 'rows,' is used to find an element with the ID 'rows.' If no such element exists, it will be created at the top of the page. The OnDomEvent target activates the targets defined in its value when the DOM is found or created, eliminating the need for conditions to verify the DOM's availability before executing the target. Additionally, the parallel property creates subtasks, which improve browser performance."
456
+
457
+ ![animation api example](https://targetj.io/img/targetjAsLibrary.gif)
458
+
459
+ ```bash
460
+ import { App, TModel, $Dom } from "targetj";
461
+
462
+ App(new TModel("rows", {
463
+ isVisible: true,
464
+ containerOverflowMode: "always",
465
+ rectTop() { return this.$dom.getBoundingClientRect().top; },
466
+ absY() { return this.val("rectTop") - $Dom.getWindowScrollTop(); },
467
+ defaultStyling: false,
468
+ domHolder: true,
469
+ onDomEvent: ["rectTop", "absY"],
470
+ onWindowScrollEvent: "absY",
471
+ createRows: {
472
+ parallel: true,
473
+ cycles: 9,
474
+ value() {
475
+ const childrenLength = this.getChildren().length;
476
+ Array.from({length: 100}, (_, i) => {
477
+ this.addChild(new TModel("row", {
478
+ keepEventDefault: true,
479
+ height: 36,
480
+ width: [{list: [100, 500, 200]}, 30],
481
+ background: "#b388ff",
482
+ canDeleteDom: false,
483
+ html: `row ${i + childrenLength}`,
484
+ }));
485
+ });
486
+ }
487
+ }
488
+ }));
489
+ ```
490
+
450
491
  ## Special target names
451
492
 
452
493
  All HTML style names and attributes are treated as special target names. The most commonly used style names and attributes have already been added to the framework, with the possibility of adding more in the future.
@@ -185,24 +185,27 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
185
185
  this.asyncStyleTargetMap[key] = true;
186
186
  }
187
187
  } else if (this.isStyleTarget(key)) {
188
+ var styleFlag = true;
188
189
  if (_TargetUtil.TargetUtil.transformMap[key]) {
189
190
  if (this.getParent()) {
190
191
  this.calcAbsolutePosition(this.getX(), this.getY());
191
192
  }
192
193
  if (_TModelUtil.TModelUtil.getTransformValue(this, key) === this.transformMap[key]) {
193
- return;
194
+ styleFlag = false;
194
195
  }
195
196
  } else if (key === 'width' || key === 'height') {
196
197
  var dimension = Math.floor(key === 'width' ? this.getWidth() : this.getHeight());
197
198
  if (this.styleMap[key] === dimension) {
198
- return;
199
+ styleFlag = false;
199
200
  }
200
201
  } else if (_TUtil.TUtil.isDefined(this.val(key)) && this.styleMap[key] === this.val(key)) {
201
- return;
202
+ styleFlag = false;
202
203
  }
203
- this.styleTargetList.push(key);
204
- this.styleTargetMap[key] = true;
205
- } else if (this.useWindowFrame(key)) {
204
+ if (styleFlag && !this.styleTargetMap[key]) {
205
+ this.styleTargetList.push(key);
206
+ this.styleTargetMap[key] = true;
207
+ }
208
+ } else if (this.useWindowFrame(key) && !this.styleTargetMap[key]) {
206
209
  this.styleTargetList.push(key);
207
210
  this.styleTargetMap[key] = true;
208
211
  } else {
@@ -146,6 +146,11 @@ var RunScheduler = exports.RunScheduler = /*#__PURE__*/function () {
146
146
  this.processRerunQueue();
147
147
  }
148
148
  }
149
+ }, {
150
+ key: "doesExecuterNeedsRerun",
151
+ value: function doesExecuterNeedsRerun() {
152
+ return _TargetExecutor.TargetExecutor.needsRerun;
153
+ }
149
154
  }, {
150
155
  key: "processRerunQueue",
151
156
  value: function processRerunQueue() {
@@ -228,13 +233,14 @@ var RunScheduler = exports.RunScheduler = /*#__PURE__*/function () {
228
233
  }
229
234
  }, {
230
235
  key: "insertRun",
231
- value: function insertRun(runId, now, delay) {
236
+ value: function insertRun(newRunId, newInsertTime, newDelay) {
232
237
  var low = 0,
233
238
  high = this.nextRuns.length;
234
239
  while (low < high) {
235
240
  var mid = Math.floor((low + high) / 2);
236
- var nextRunDelay = this.nextRuns[mid].delay;
237
- var diff = nextRunDelay - delay;
241
+ var delay = this.nextRuns[mid].delay;
242
+ var insertTime = this.nextRuns[mid].insertTime;
243
+ var diff = insertTime + delay - (newInsertTime + newDelay);
238
244
  if (diff > 0) {
239
245
  high = mid;
240
246
  } else if (diff < 0) {
@@ -244,9 +250,9 @@ var RunScheduler = exports.RunScheduler = /*#__PURE__*/function () {
244
250
  }
245
251
  }
246
252
  this.nextRuns.splice(low, 0, {
247
- runId: runId,
248
- insertTime: now,
249
- delay: delay
253
+ runId: newRunId,
254
+ insertTime: newInsertTime,
255
+ delay: newDelay
250
256
  });
251
257
  }
252
258
  }]);
@@ -120,6 +120,9 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
120
120
  if (tmodel.isScheduledPending(key)) {
121
121
  continue;
122
122
  }
123
+ if (!tmodel.hasDom() && tmodel.allStyleTargetMap[key]) {
124
+ continue;
125
+ }
123
126
  schedulePeriod = _TargetUtil.TargetUtil.scheduleExecution(tmodel, key);
124
127
  if (schedulePeriod > 0) {
125
128
  (0, _App.getRunScheduler)().schedule(schedulePeriod, "setActualValues-".concat(tmodel.oid, "__").concat(key, "_").concat(schedulePeriod));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.120",
3
+ "version": "1.0.122",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],