@plcmp/pl-virtual-scroll 0.1.9 → 0.1.11
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 +19 -11
package/package.json
CHANGED
package/pl-virtual-scroll.js
CHANGED
|
@@ -74,7 +74,7 @@ class PlVirtualScroll extends PlElement {
|
|
|
74
74
|
let [, index, ...rest] = normalizePath(mutation.path);
|
|
75
75
|
switch (mutation.action) {
|
|
76
76
|
case 'upd':
|
|
77
|
-
if(mutation.oldValue
|
|
77
|
+
if(Array.isArray(mutation.value) && Array.isArray(mutation.oldValue) && mutation.oldValue.length == mutation.value.length) {
|
|
78
78
|
this.phyPool.forEach(i => {
|
|
79
79
|
i.ctx.replace(this.items[i.index]);
|
|
80
80
|
i.ctx.applyEffects();
|
|
@@ -94,21 +94,29 @@ class PlVirtualScroll extends PlElement {
|
|
|
94
94
|
break;
|
|
95
95
|
case 'splice':
|
|
96
96
|
let { index: spliceIndex } = mutation;
|
|
97
|
+
// if mutation is not root try to apply effects to childs (need when pushing to arrya inside array)
|
|
98
|
+
if(rest.length > 0) {
|
|
99
|
+
let path = [this.as, ...rest].join('.');
|
|
100
|
+
this.phyPool[index].ctx.applyEffects({ ...mutation, path });
|
|
101
|
+
} else {
|
|
102
|
+
this.phyPool.forEach(i => {
|
|
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
|
+
|
|
106
|
+
i.ctx.replace(this.items[i.index]);
|
|
107
|
+
i.ctx.applyEffects();
|
|
108
|
+
i.ctx._ti.applyBinds();
|
|
109
|
+
} else if (i.index >= this.items.length) {
|
|
110
|
+
i.index = null;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
97
114
|
|
|
98
115
|
//TODO: add more Heuristic to scroll list if visible elements that not changed? like insert rows before
|
|
99
116
|
// visible area
|
|
100
117
|
|
|
101
118
|
//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
|
-
});
|
|
119
|
+
|
|
112
120
|
setTimeout(() => this.render(), 0);
|
|
113
121
|
|
|
114
122
|
break;
|