targetj 1.0.94 → 1.0.95

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
@@ -350,46 +350,44 @@ This example demonstrates how to handle scroll events and develop a simple infin
350
350
  ```bash
351
351
  import { App, TModel, getEvents, getScreenHeight, getScreenWidth, } from "targetj";
352
352
 
353
- App(
354
- new TModel("scroller", {
355
- canHandleEvents: "scrollTop",
353
+ App(new TModel("scroller", {
354
+ canHandleEvents: 'scrollTop',
356
355
  innerXEast: 0,
357
- addChildren: {
358
- loop() {
359
- return this.inFlowVisibles.length * 32 < this.getHeight();
360
- },
361
- value() {
362
- const childrenCount = this.getChildren().length;
363
- for (let i = 0; i < 10; i++) {
364
- this.addChild(
365
- new TModel("scrollItem", {
366
- width: 300,
367
- background: "brown",
368
- height: 30,
369
- lineHeight: 30,
370
- color: "#fff",
371
- style: { textAlign: "center" },
372
- bottomMargin: 2,
373
- x() { return (this.getParentValue("width") - this.getWidth()) / 2; },
374
- html: childrenCount + i + 1,
375
- })
376
- );
377
- }
378
- },
379
- enabledOn() {
380
- return this.inFlowVisibles.length * 32 < this.getHeight();
381
- },
382
- },
383
- scrollTop(cycle, lastValue) {
384
- return Math.max(0, lastValue + getEvents().deltaY());
356
+ children: {
357
+ value() {
358
+ const childrenCount = this.getChildren().length;
359
+ return Array.from({ length: 5 }, (_, i) =>
360
+ new TModel('scrollItem', {
361
+ width: 300,
362
+ background: 'brown',
363
+ height: 30,
364
+ color: '#fff',
365
+ style: {
366
+ textAlign: 'center',
367
+ lineHeight: '30px'
368
+ },
369
+ bottomMargin: 2,
370
+ x() { return (this.getParentValue('width') - this.getWidth()) / 2; },
371
+ html: childrenCount + i,
372
+ domParent() {
373
+ return this.getParent();
374
+ }
375
+ })
376
+ );
377
+ },
378
+ enabledOn() {
379
+ return this.visibleChildren.length * 32 < this.getHeight();
380
+ }
385
381
  },
386
- width: getScreenWidth,
387
- height: getScreenHeight,
388
- onResize: ["width", "height"],
389
- onScrollEvent: ["scrollTop", "addChildren"],
390
- })
391
- );
392
-
382
+ scrollTop(cycle, lastValue) {
383
+ return Math.max(0, lastValue + getEvents().deltaY());
384
+ },
385
+ width() { return getScreenWidth(); },
386
+ height() { return getScreenHeight(); },
387
+ onResize: [ 'width', 'height' ],
388
+ onScrollEvent: [ 'scrollTop', 'children' ],
389
+ onVisibleChildrenChange: [ 'children' ]
390
+ }));
393
391
  ```
394
392
 
395
393
  ## Simple Single Page App Example
@@ -25,7 +25,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
25
25
  var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
26
26
  function BaseModel(type, targets) {
27
27
  _classCallCheck(this, BaseModel);
28
- if (arguments.length === 1 && _typeof(type) === 'object') {
28
+ if (_typeof(type) === 'object' && typeof targets === 'undefined') {
29
29
  targets = type;
30
30
  type = "";
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.94",
3
+ "version": "1.0.95",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],