@neovici/cosmoz-bottom-bar 9.0.1 → 9.0.2

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.
Files changed (2) hide show
  1. package/dist/overflow.js +20 -5
  2. package/package.json +1 -1
package/dist/overflow.js CHANGED
@@ -10,12 +10,13 @@ const check = (part) => {
10
10
  }
11
11
  };
12
12
  const setupObserver = (slot, onOverflow) => {
13
- const visible = new Set();
14
- const overflowing = new Set();
13
+ let visible = new Set();
14
+ let overflowing = new Set();
15
15
  const observer = new IntersectionObserver((entries) => {
16
16
  entries.forEach((entry) => {
17
17
  const el = entry.target;
18
- if (entry.intersectionRatio === 1) {
18
+ if (entry.boundingClientRect.width === entry.intersectionRect.width &&
19
+ entry.intersectionRect.height !== 0) {
19
20
  visible.add(el);
20
21
  overflowing.delete(el);
21
22
  }
@@ -29,12 +30,26 @@ const setupObserver = (slot, onOverflow) => {
29
30
  }
30
31
  });
31
32
  onOverflow({ visible, overflowing });
32
- }, { root: slot.parentElement, threshold: 1 });
33
+ }, { root: slot.parentElement, threshold: [0, 0.5, 1] });
33
34
  const observe = () => {
34
35
  const elements = Array.from(slot.assignedElements({ flatten: true }));
36
+ const newVisible = new Set();
37
+ const newOverflowing = new Set();
35
38
  for (const c of elements) {
36
- observer.observe(c);
39
+ if (visible.has(c)) {
40
+ newVisible.add(c);
41
+ }
42
+ else if (overflowing.has(c)) {
43
+ newOverflowing.add(c);
44
+ }
45
+ else {
46
+ observer.observe(c);
47
+ newVisible.add(c);
48
+ }
37
49
  }
50
+ visible = newVisible;
51
+ overflowing = newOverflowing;
52
+ onOverflow({ visible, overflowing });
38
53
  };
39
54
  observe();
40
55
  slot.addEventListener('slotchange', observe);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-bottom-bar",
3
- "version": "9.0.1",
3
+ "version": "9.0.2",
4
4
  "description": "A responsive bottom-bar that can house buttons/actions and a menu for the buttons that won't fit the available width.",
5
5
  "keywords": [
6
6
  "polymer",