@plcmp/pl-virtual-scroll 0.1.10 → 0.1.12
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 +25 -10
package/package.json
CHANGED
package/pl-virtual-scroll.js
CHANGED
|
@@ -81,6 +81,12 @@ class PlVirtualScroll extends PlElement {
|
|
|
81
81
|
i.ctx._ti.applyBinds();
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
// Временный решение, занулям физический пулл в случаях когда значения массива приходят внутри объектов
|
|
86
|
+
// Исправить в будущем на более умную замену значений
|
|
87
|
+
if(Array.isArray(mutation.value) && Array.isArray(mutation.oldValue) && mutation.oldValue.length != mutation.value.length) {
|
|
88
|
+
this.phyPool = [];
|
|
89
|
+
}
|
|
84
90
|
if (index !== undefined && +index >= 0) {
|
|
85
91
|
let el = this.phyPool.find(i => i.index === +index);
|
|
86
92
|
if (el && rest.length > 0) {
|
|
@@ -94,21 +100,29 @@ class PlVirtualScroll extends PlElement {
|
|
|
94
100
|
break;
|
|
95
101
|
case 'splice':
|
|
96
102
|
let { index: spliceIndex } = mutation;
|
|
103
|
+
// if mutation is not root try to apply effects to childs (need when pushing to arrya inside array)
|
|
104
|
+
if(rest.length > 0) {
|
|
105
|
+
let path = [this.as, ...rest].join('.');
|
|
106
|
+
this.phyPool[index].ctx.applyEffects({ ...mutation, path });
|
|
107
|
+
} else {
|
|
108
|
+
this.phyPool.forEach(i => {
|
|
109
|
+
if (i.index !== null && i.index >= spliceIndex && i.index < this.items.length) {
|
|
110
|
+
if (this.items[i.index] instanceof PlaceHolder) this.items.load?.(this.items[i.index]);
|
|
111
|
+
|
|
112
|
+
i.ctx.replace(this.items[i.index]);
|
|
113
|
+
i.ctx.applyEffects();
|
|
114
|
+
i.ctx._ti.applyBinds();
|
|
115
|
+
} else if (i.index >= this.items.length) {
|
|
116
|
+
i.index = null;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
97
120
|
|
|
98
121
|
//TODO: add more Heuristic to scroll list if visible elements that not changed? like insert rows before
|
|
99
122
|
// visible area
|
|
100
123
|
|
|
101
124
|
//refresh all PHY if they can be affected
|
|
102
|
-
|
|
103
|
-
if (i.index !== null && i.index >= spliceIndex && i.index < this.items.length) {
|
|
104
|
-
if (this.items[i.index] instanceof PlaceHolder) this.items.load?.(this.items[i.index]);
|
|
105
|
-
i.ctx.replace(this.items[i.index]);
|
|
106
|
-
i.ctx.applyEffects();
|
|
107
|
-
i.ctx._ti.applyBinds();
|
|
108
|
-
} else if (i.index >= this.items.length) {
|
|
109
|
-
i.index = null;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
125
|
+
|
|
112
126
|
setTimeout(() => this.render(), 0);
|
|
113
127
|
|
|
114
128
|
break;
|
|
@@ -217,6 +231,7 @@ class PlVirtualScroll extends PlElement {
|
|
|
217
231
|
if (n.style) {
|
|
218
232
|
n.style.transform = `translateY(${target.offset}px)`;
|
|
219
233
|
n.style.position = 'absolute';
|
|
234
|
+
n.setAttribute('virtualOffser', target.offset);
|
|
220
235
|
}
|
|
221
236
|
});
|
|
222
237
|
return target;
|