@plcmp/pl-virtual-scroll 1.0.2 → 1.0.4
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 +28 -24
package/package.json
CHANGED
package/pl-virtual-scroll.js
CHANGED
|
@@ -100,33 +100,36 @@ class PlVirtualScroll extends PlElement {
|
|
|
100
100
|
setTimeout(() => this.render(), 0);
|
|
101
101
|
}
|
|
102
102
|
break;
|
|
103
|
+
|
|
103
104
|
case 'splice': {
|
|
104
105
|
let { index: spliceIndex } = mutation;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
i.index
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
106
|
+
if (Number(index) >= 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
|
+
}
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
// TODO: add more Heuristic to scroll list if visible elements that not changed? like insert rows before
|
|
128
|
+
// visible area
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
// refresh all PHY if they can be affected
|
|
131
|
+
setTimeout(() => this.render(), 0);
|
|
132
|
+
}
|
|
130
133
|
|
|
131
134
|
break;
|
|
132
135
|
}
|
|
@@ -211,8 +214,9 @@ class PlVirtualScroll extends PlElement {
|
|
|
211
214
|
: 32; // TODO: replace w/o constant
|
|
212
215
|
const predictedStart = Math.min(Math.ceil(this.canvas.parentNode.scrollTop / heightForStart), this.items.length - 1);
|
|
213
216
|
firstShadow = lastShadow = this.renderItem(predictedStart, unused.pop(), this.canvas.parentNode.scrollTop);
|
|
214
|
-
used.unshift(firstShadow);
|
|
215
217
|
}
|
|
218
|
+
|
|
219
|
+
used.unshift(firstShadow);
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
// render forward
|