@vaadin/component-base 25.0.7 → 25.0.8
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": "25.0.
|
|
3
|
+
"version": "25.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"lit": "^3.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@vaadin/chai-plugins": "~25.0.
|
|
41
|
-
"@vaadin/test-runner-commands": "~25.0.
|
|
40
|
+
"@vaadin/chai-plugins": "~25.0.8",
|
|
41
|
+
"@vaadin/test-runner-commands": "~25.0.8",
|
|
42
42
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
43
43
|
"sinon": "^21.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "d49b389a8188b9695abc566d7efa163fe9c1b130"
|
|
46
46
|
}
|
package/src/define.js
CHANGED
|
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
|
|
|
13
13
|
|
|
14
14
|
const experimentalMap = {};
|
|
15
15
|
|
|
16
|
-
export function defineCustomElement(CustomElement, version = '25.0.
|
|
16
|
+
export function defineCustomElement(CustomElement, version = '25.0.8') {
|
|
17
17
|
Object.defineProperty(CustomElement, 'version', {
|
|
18
18
|
get() {
|
|
19
19
|
return version;
|
package/src/element-mixin.d.ts
CHANGED
package/src/element-mixin.js
CHANGED
|
@@ -38,9 +38,7 @@ const registered = new Set();
|
|
|
38
38
|
export const ElementMixin = (superClass) =>
|
|
39
39
|
class VaadinElementMixin extends DirMixin(superClass) {
|
|
40
40
|
/** @protected */
|
|
41
|
-
static
|
|
42
|
-
super.finalize();
|
|
43
|
-
|
|
41
|
+
static _ensureRegistrations() {
|
|
44
42
|
const { is } = this;
|
|
45
43
|
|
|
46
44
|
// Registers a class prototype for telemetry purposes.
|
|
@@ -66,5 +64,7 @@ export const ElementMixin = (superClass) =>
|
|
|
66
64
|
'Vaadin components require the "standards mode" declaration. Please add <!DOCTYPE html> to the HTML document.',
|
|
67
65
|
);
|
|
68
66
|
}
|
|
67
|
+
|
|
68
|
+
this.constructor._ensureRegistrations();
|
|
69
69
|
}
|
|
70
70
|
};
|
|
@@ -333,6 +333,19 @@ export class IronListAdapter {
|
|
|
333
333
|
return element ? this.scrollTarget.getBoundingClientRect().top - element.getBoundingClientRect().top : undefined;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Adjusts the scroll position to compensate for any offset change of a given index.
|
|
338
|
+
* @param {number} index - The index whose scroll offset to restore
|
|
339
|
+
* @param {number|undefined} offsetBefore - The scroll offset of the index before the change
|
|
340
|
+
* @private
|
|
341
|
+
*/
|
|
342
|
+
__restoreScrollOffset(index, offsetBefore) {
|
|
343
|
+
const offsetAfter = this.__getIndexScrollOffset(index);
|
|
344
|
+
if (offsetBefore !== undefined && offsetAfter !== undefined) {
|
|
345
|
+
this._scrollTop += offsetBefore - offsetAfter;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
336
349
|
get size() {
|
|
337
350
|
return this.__size;
|
|
338
351
|
}
|
|
@@ -382,10 +395,7 @@ export class IronListAdapter {
|
|
|
382
395
|
// and remove exceeding items when size is decreased.
|
|
383
396
|
this.scrollToIndex(fvi);
|
|
384
397
|
|
|
385
|
-
|
|
386
|
-
if (fviOffsetBefore !== undefined && fviOffsetAfter !== undefined) {
|
|
387
|
-
this._scrollTop += fviOffsetBefore - fviOffsetAfter;
|
|
388
|
-
}
|
|
398
|
+
this.__restoreScrollOffset(fvi, fviOffsetBefore);
|
|
389
399
|
}
|
|
390
400
|
|
|
391
401
|
this.__preventElementUpdates = false;
|
|
@@ -851,27 +861,43 @@ export class IronListAdapter {
|
|
|
851
861
|
const threshold = OFFSET_ADJUST_MIN_THRESHOLD;
|
|
852
862
|
const maxShift = 100;
|
|
853
863
|
|
|
864
|
+
// Lazily capture scroll state before the first offset change,
|
|
865
|
+
// so it can be restored afterwards.
|
|
866
|
+
let fvi, fviOffsetBefore;
|
|
867
|
+
const captureScrollState = () => {
|
|
868
|
+
fvi = this.adjustedFirstVisibleIndex;
|
|
869
|
+
fviOffsetBefore = this.__getIndexScrollOffset(fvi);
|
|
870
|
+
};
|
|
871
|
+
|
|
854
872
|
// Near start
|
|
855
873
|
if (this._scrollTop === 0) {
|
|
856
|
-
|
|
857
|
-
|
|
874
|
+
if (oldOffset !== 0) {
|
|
875
|
+
captureScrollState();
|
|
876
|
+
this._vidxOffset = 0;
|
|
858
877
|
super.scrollToIndex(0);
|
|
859
878
|
}
|
|
860
879
|
} else if (this.firstVisibleIndex < threshold && this._vidxOffset > 0) {
|
|
880
|
+
captureScrollState();
|
|
861
881
|
this._vidxOffset -= Math.min(this._vidxOffset, maxShift);
|
|
862
882
|
super.scrollToIndex(this.firstVisibleIndex + (oldOffset - this._vidxOffset));
|
|
863
883
|
}
|
|
864
884
|
|
|
865
885
|
// Near end
|
|
866
886
|
if (this._scrollTop >= this._maxScrollTop && this._maxScrollTop > 0) {
|
|
867
|
-
|
|
868
|
-
|
|
887
|
+
if (oldOffset !== maxOffset) {
|
|
888
|
+
captureScrollState();
|
|
889
|
+
this._vidxOffset = maxOffset;
|
|
869
890
|
super.scrollToIndex(this._virtualCount - 1);
|
|
870
891
|
}
|
|
871
892
|
} else if (this.firstVisibleIndex > this._virtualCount - threshold && this._vidxOffset < maxOffset) {
|
|
893
|
+
captureScrollState();
|
|
872
894
|
this._vidxOffset += Math.min(maxOffset - this._vidxOffset, maxShift);
|
|
873
895
|
super.scrollToIndex(this.firstVisibleIndex - (this._vidxOffset - oldOffset));
|
|
874
896
|
}
|
|
897
|
+
|
|
898
|
+
if (fvi !== undefined) {
|
|
899
|
+
this.__restoreScrollOffset(fvi, fviOffsetBefore);
|
|
900
|
+
}
|
|
875
901
|
}
|
|
876
902
|
}
|
|
877
903
|
}
|