@plcmp/pl-virtual-scroll 0.1.13 → 0.1.14

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": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Component for lazy list render.",
5
5
  "main": "pl-virtual-scroll.js",
6
6
  "repository": {
@@ -22,7 +22,7 @@ class PlVirtualScroll extends PlElement {
22
22
  renderedStart: { type: Number, value: 0 },
23
23
  renderedCount: { type: Number, value: 0 },
24
24
  phyItems: { type: Array, value: () => [] },
25
- canvas: { type: Object },
25
+ canvas: { type: Object }
26
26
  }
27
27
  static template = html`
28
28
  <style>
@@ -147,8 +147,8 @@ class PlVirtualScroll extends PlElement {
147
147
  /*let first = Math.floor(offset / this.elementHeight);
148
148
  let last = Math.ceil((offset+height) / this.elementHeight);*/
149
149
  // Reset scroll position if update data smaller than current visible index
150
- if (!scroll && this.items.length < (offset + height * 1.5) / this.elementHeight) {
151
- canvas.parentNode.scrollTop = 0;
150
+ if (!scroll && this.items.length < Math.floor((offset + height) / this.elementHeight)) {
151
+ canvas.parentNode.scrollTop = this.items.length * this.elementHeight - height;
152
152
  }
153
153
  let shadowEnd = Math.min(this.items.length, Math.ceil((offset + height * 1.5) / this.elementHeight));
154
154
  let shadowBegin = Math.max(0, Math.floor(Math.min((offset - height / 2) / this.elementHeight, shadowEnd - height * 2 / this.elementHeight)));
@@ -232,7 +232,7 @@ class PlVirtualScroll extends PlElement {
232
232
  if (n.style) {
233
233
  n.style.transform = `translateY(${target.offset}px)`;
234
234
  n.style.position = 'absolute';
235
- n.setAttribute('virtualOffser', target.offset);
235
+ n.setAttribute('virtualOffset', target.offset);
236
236
  }
237
237
  });
238
238
  return target;