@vaadin/component-base 24.3.10 → 24.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "24.3.10",
3
+ "version": "24.3.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,5 +42,5 @@
42
42
  "@vaadin/testing-helpers": "^0.6.0",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "32a4f327e78490074eaefa768f58857b83ca6278"
45
+ "gitHead": "890abeb0937416074456782aa90ed92c1bfe9cac"
46
46
  }
package/src/define.js CHANGED
@@ -9,7 +9,7 @@ export function defineCustomElement(CustomElement) {
9
9
  if (!defined) {
10
10
  Object.defineProperty(CustomElement, 'version', {
11
11
  get() {
12
- return '24.3.10';
12
+ return '24.3.11';
13
13
  },
14
14
  });
15
15
 
@@ -82,6 +82,10 @@ export class IronListAdapter {
82
82
  return this.lastVisibleIndex + this._vidxOffset;
83
83
  }
84
84
 
85
+ get _maxVirtualIndexOffset() {
86
+ return this.size - this._virtualCount;
87
+ }
88
+
85
89
  __hasPlaceholders() {
86
90
  return this.__getVisibleElements().some((el) => el.__virtualizerPlaceholder);
87
91
  }
@@ -106,7 +110,7 @@ export class IronListAdapter {
106
110
  let targetVirtualIndex = Math.floor((index / this.size) * this._virtualCount);
107
111
  if (this._virtualCount - targetVirtualIndex < visibleElementCount) {
108
112
  targetVirtualIndex = this._virtualCount - (this.size - index);
109
- this._vidxOffset = this.size - this._virtualCount;
113
+ this._vidxOffset = this._maxVirtualIndexOffset;
110
114
  } else if (targetVirtualIndex < visibleElementCount) {
111
115
  if (index < OFFSET_ADJUST_MIN_THRESHOLD) {
112
116
  targetVirtualIndex = index;
@@ -719,15 +723,16 @@ export class IronListAdapter {
719
723
 
720
724
  /** @private */
721
725
  _adjustVirtualIndexOffset(delta) {
726
+ const maxOffset = this._maxVirtualIndexOffset;
727
+
722
728
  if (this._virtualCount >= this.size) {
723
729
  this._vidxOffset = 0;
724
730
  } else if (this.__skipNextVirtualIndexAdjust) {
725
731
  this.__skipNextVirtualIndexAdjust = false;
726
732
  } else if (Math.abs(delta) > 10000) {
727
733
  // Process a large scroll position change
728
- const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.offsetHeight);
729
- const offset = scale * this.size;
730
- this._vidxOffset = Math.round(offset - scale * this._virtualCount);
734
+ const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.clientHeight);
735
+ this._vidxOffset = Math.round(scale * maxOffset);
731
736
  } else {
732
737
  // Make sure user can always swipe/wheel scroll to the start and end
733
738
  const oldOffset = this._vidxOffset;
@@ -746,7 +751,6 @@ export class IronListAdapter {
746
751
  }
747
752
 
748
753
  // Near end
749
- const maxOffset = this.size - this._virtualCount;
750
754
  if (this._scrollTop >= this._maxScrollTop && this._maxScrollTop > 0) {
751
755
  this._vidxOffset = maxOffset;
752
756
  if (oldOffset !== this._vidxOffset) {