@plcmp/pl-virtual-scroll 1.0.5 → 1.0.6
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/package.json +1 -1
- package/pl-virtual-scroll.js +26 -24
package/package.json
CHANGED
package/pl-virtual-scroll.js
CHANGED
|
@@ -102,32 +102,34 @@ class PlVirtualScroll extends PlElement {
|
|
|
102
102
|
break;
|
|
103
103
|
|
|
104
104
|
case 'splice': {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
i.index
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
105
|
+
const { index: spliceIndex } = mutation;
|
|
106
|
+
if (Number(spliceIndex) >= 0) {
|
|
107
|
+
// if mutation is not root try to apply effects to children (need when pushing to array inside array)
|
|
108
|
+
if (rest.length > 0) {
|
|
109
|
+
let path = [this.as, ...rest].join('.');
|
|
110
|
+
this.phyPool[index].ctx.applyEffects({...mutation, path});
|
|
111
|
+
} else {
|
|
112
|
+
this.phyPool.forEach((i) => {
|
|
113
|
+
if (i.index !== null && i.index >= spliceIndex && i.index < this.items.length) {
|
|
114
|
+
if (this.items[i.index] instanceof PlaceHolder) this.items.load?.(this.items[i.index]);
|
|
115
|
+
|
|
116
|
+
i.ctx.replace(this.items[i.index]);
|
|
117
|
+
i.ctx.applyEffects(undefined);
|
|
118
|
+
i.ctx._ti.applyBinds();
|
|
119
|
+
} else if (i.index >= this.items.length) {
|
|
120
|
+
i.index = null;
|
|
121
|
+
i.offset = -10000;
|
|
122
|
+
fixOffset(i);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
// TODO: add more Heuristic to scroll list if visible elements that not changed? like insert rows before
|
|
128
|
+
// visible area
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
// refresh all PHY if they can be affected
|
|
131
|
+
setTimeout(() => this.render(), 0);
|
|
132
|
+
}
|
|
131
133
|
|
|
132
134
|
break;
|
|
133
135
|
}
|