@vaadin/overlay 24.8.6 → 24.8.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/overlay",
3
- "version": "24.8.6",
3
+ "version": "24.8.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,18 +36,18 @@
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/a11y-base": "~24.8.6",
40
- "@vaadin/component-base": "~24.8.6",
41
- "@vaadin/vaadin-lumo-styles": "~24.8.6",
42
- "@vaadin/vaadin-material-styles": "~24.8.6",
43
- "@vaadin/vaadin-themable-mixin": "~24.8.6",
39
+ "@vaadin/a11y-base": "~24.8.8",
40
+ "@vaadin/component-base": "~24.8.8",
41
+ "@vaadin/vaadin-lumo-styles": "~24.8.8",
42
+ "@vaadin/vaadin-material-styles": "~24.8.8",
43
+ "@vaadin/vaadin-themable-mixin": "~24.8.8",
44
44
  "lit": "^3.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@vaadin/chai-plugins": "~24.8.6",
48
- "@vaadin/test-runner-commands": "~24.8.6",
47
+ "@vaadin/chai-plugins": "~24.8.8",
48
+ "@vaadin/test-runner-commands": "~24.8.8",
49
49
  "@vaadin/testing-helpers": "^1.1.0",
50
50
  "sinon": "^18.0.0"
51
51
  },
52
- "gitHead": "811e267191812c5ac9f1f010782d746785d0fde5"
52
+ "gitHead": "992c7e745638819544e6814dd54d108c15f8163b"
53
53
  }
@@ -16,10 +16,12 @@
16
16
  */
17
17
  export function observeMove(element, callback) {
18
18
  let io = null;
19
+ let timeout;
19
20
 
20
21
  const root = document.documentElement;
21
22
 
22
23
  function cleanup() {
24
+ timeout && clearTimeout(timeout);
23
25
  io && io.disconnect();
24
26
  io = null;
25
27
  }
@@ -52,27 +54,22 @@ export function observeMove(element, callback) {
52
54
  let isFirstUpdate = true;
53
55
 
54
56
  function handleObserve(entries) {
55
- let ratio = entries[0].intersectionRatio;
57
+ const ratio = entries[0].intersectionRatio;
56
58
 
57
59
  if (ratio !== threshold) {
58
60
  if (!isFirstUpdate) {
59
61
  return refresh();
60
62
  }
61
63
 
62
- // It's possible for the watched element to not be at perfect 1.0 visibility when we create
63
- // the IntersectionObserver. This has a couple of causes:
64
- // - elements being on partial pixels
65
- // - elements being hidden offscreen (e.g., <html> has `overflow: hidden`)
66
- // - delays: if your DOM change occurs due to e.g., page resize, you can see elements
67
- // behind their actual position
68
- //
69
- // In all of these cases, refresh but with this lower ratio of threshold. When the element
70
- // moves beneath _that_ new value, the user will get notified.
71
- if (ratio === 0.0) {
72
- ratio = 0.0000001; // Just needs to be non-zero
64
+ if (!ratio) {
65
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
66
+ // to prevent an infinite loop of updates.
67
+ timeout = setTimeout(() => {
68
+ refresh(false, 1e-7);
69
+ }, 1000);
70
+ } else {
71
+ refresh(false, ratio);
73
72
  }
74
-
75
- refresh(false, ratio);
76
73
  }
77
74
 
78
75
  isFirstUpdate = false;