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