@vaadin/component-base 25.2.0-alpha5 → 25.2.0-alpha6

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.2.0-alpha5",
3
+ "version": "25.2.0-alpha6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,11 +38,11 @@
38
38
  "lit": "^3.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@vaadin/chai-plugins": "25.2.0-alpha5",
42
- "@vaadin/test-runner-commands": "25.2.0-alpha5",
41
+ "@vaadin/chai-plugins": "25.2.0-alpha6",
42
+ "@vaadin/test-runner-commands": "25.2.0-alpha6",
43
43
  "@vaadin/testing-helpers": "^2.0.0",
44
44
  "sinon": "^21.0.2"
45
45
  },
46
46
  "customElements": "custom-elements.json",
47
- "gitHead": "2f0c822a389571591b1b9d2c27d45e008ccbae6b"
47
+ "gitHead": "30f23c65765f27616f2db292406d5759a7e987c3"
48
48
  }
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.2.0-alpha5') {
16
+ export function defineCustomElement(CustomElement, version = '25.2.0-alpha6') {
17
17
  Object.defineProperty(CustomElement, 'version', {
18
18
  get() {
19
19
  return version;
@@ -3,8 +3,6 @@
3
3
  * Copyright (c) 2021 - 2026 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { animationFrame } from './async.js';
7
- import { Debouncer } from './debounce.js';
8
6
 
9
7
  /**
10
8
  * A controller that detects if content inside the element overflows its scrolling viewport,
@@ -48,12 +46,7 @@ export class OverflowController {
48
46
  observe() {
49
47
  const { host } = this;
50
48
 
51
- this.__resizeObserver = new ResizeObserver(() => {
52
- this.__debounceOverflow = Debouncer.debounce(this.__debounceOverflow, animationFrame, () => {
53
- this.__updateOverflow();
54
- });
55
- });
56
-
49
+ this.__resizeObserver = new ResizeObserver(() => this.__onResize());
57
50
  this.__resizeObserver.observe(host);
58
51
 
59
52
  // Observe initial children
@@ -74,26 +67,43 @@ export class OverflowController {
74
67
  this.__resizeObserver.unobserve(node);
75
68
  }
76
69
  });
77
- });
78
70
 
79
- this.__updateOverflow();
71
+ if (addedNodes.length === 0 && removedNodes.length > 0) {
72
+ this.__updateState({ sync: true });
73
+ }
74
+ });
80
75
  });
81
76
 
82
77
  this.__childObserver.observe(host, { childList: true });
83
78
 
84
79
  // Update overflow attribute on scroll
85
80
  this.scrollTarget.addEventListener('scroll', this.__boundOnScroll);
81
+ }
86
82
 
87
- this.__updateOverflow();
83
+ /** @private */
84
+ __onResize() {
85
+ this.__updateState({ sync: false });
88
86
  }
89
87
 
90
88
  /** @private */
91
89
  __onScroll() {
92
- this.__updateOverflow();
90
+ this.__updateState({ sync: true });
93
91
  }
94
92
 
95
93
  /** @private */
96
- __updateOverflow() {
94
+ __updateState({ sync }) {
95
+ cancelAnimationFrame(this.__resizeRaf);
96
+
97
+ const state = this.__readState();
98
+ if (sync) {
99
+ this.__writeState(state);
100
+ } else {
101
+ this.__resizeRaf = requestAnimationFrame(() => this.__writeState(state));
102
+ }
103
+ }
104
+
105
+ /** @private */
106
+ __readState() {
97
107
  const target = this.scrollTarget;
98
108
 
99
109
  let overflow = '';
@@ -115,10 +125,14 @@ export class OverflowController {
115
125
  overflow += ' end';
116
126
  }
117
127
 
118
- overflow = overflow.trim();
119
- if (overflow.length > 0 && this.host.getAttribute('overflow') !== overflow) {
128
+ return { overflow: overflow.trim() };
129
+ }
130
+
131
+ /** @private */
132
+ __writeState({ overflow }) {
133
+ if (overflow) {
120
134
  this.host.setAttribute('overflow', overflow);
121
- } else if (overflow.length === 0 && this.host.hasAttribute('overflow')) {
135
+ } else {
122
136
  this.host.removeAttribute('overflow');
123
137
  }
124
138
  }
@@ -78,8 +78,6 @@ export class IronListAdapter {
78
78
  });
79
79
  attachObserver.observe(this.scrollTarget);
80
80
 
81
- this._scrollLineHeight = this._getScrollLineHeight();
82
-
83
81
  this.scrollTarget.addEventListener('virtualizer-element-focused', (e) => this.__onElementFocused(e));
84
82
  this.elementsContainer.addEventListener('focusin', () => {
85
83
  this.scrollTarget.dispatchEvent(
@@ -462,10 +460,6 @@ export class IronListAdapter {
462
460
  this._isRTL = Boolean(styles.direction === 'rtl');
463
461
  this._viewportWidth = this.elementsContainer.offsetWidth;
464
462
  this._viewportHeight = this.scrollTarget.offsetHeight;
465
- this._scrollPageHeight = this._viewportHeight - this._scrollLineHeight;
466
- if (this.grid) {
467
- this._updateGridMetrics();
468
- }
469
463
  }
470
464
 
471
465
  /** @private */
@@ -780,20 +774,6 @@ export class IronListAdapter {
780
774
  return 0;
781
775
  }
782
776
 
783
- /**
784
- * @returns {Number|undefined} - The browser's default font-size in pixels
785
- * @private
786
- */
787
- _getScrollLineHeight() {
788
- const el = document.createElement('div');
789
- el.style.fontSize = 'initial';
790
- el.style.display = 'none';
791
- document.body.appendChild(el);
792
- const fontSize = window.getComputedStyle(el).fontSize;
793
- document.body.removeChild(el);
794
- return fontSize ? window.parseInt(fontSize) : undefined;
795
- }
796
-
797
777
  __getVisibleElements() {
798
778
  return Array.from(this.elementsContainer.children).filter((element) => !element.hidden);
799
779
  }