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 +36 -38
- package/build/BaseModel.js +1 -1
- package/package.json +1 -1
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
|
-
|
|
355
|
-
canHandleEvents: "scrollTop",
|
|
353
|
+
App(new TModel("scroller", {
|
|
354
|
+
canHandleEvents: 'scrollTop',
|
|
356
355
|
innerXEast: 0,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
package/build/BaseModel.js
CHANGED
|
@@ -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 (
|
|
28
|
+
if (_typeof(type) === 'object' && typeof targets === 'undefined') {
|
|
29
29
|
targets = type;
|
|
30
30
|
type = "";
|
|
31
31
|
}
|