@pictogrammers/components 0.5.26 → 0.5.27
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
|
@@ -63,7 +63,9 @@ export default class PgOverlayMenu extends PgOverlay {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}, {
|
|
66
|
+
// @ts-ignore
|
|
66
67
|
trackVisibility: true,
|
|
68
|
+
delay: 100,
|
|
67
69
|
root: null, // Defaults to the browser viewport
|
|
68
70
|
threshold: 0 // Triggers as soon as even 1 pixel enters or leaves
|
|
69
71
|
});
|
|
@@ -77,18 +77,26 @@ export default class PgOverlaySelectMenu extends PgOverlay {
|
|
|
77
77
|
this.$overlay.style.setProperty('--pg-overlay-menu-_y', `${y}px`);
|
|
78
78
|
// Focus
|
|
79
79
|
this.$menu.focus(index);
|
|
80
|
-
//
|
|
81
|
-
const observer = new IntersectionObserver((
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
80
|
+
// Keep the menu fully within the viewport once its real size is known
|
|
81
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
82
|
+
observer.disconnect();
|
|
83
|
+
if (entry.intersectionRatio === 1) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const { top, bottom } = entry.boundingClientRect;
|
|
87
|
+
const viewportHeight = entry.rootBounds?.height ?? window.innerHeight;
|
|
88
|
+
let offset = 0;
|
|
89
|
+
if (bottom > viewportHeight) {
|
|
90
|
+
offset = viewportHeight - bottom;
|
|
91
|
+
}
|
|
92
|
+
// Prefer keeping the top edge visible over the bottom if it can't fully fit
|
|
93
|
+
if (top + offset < 0) {
|
|
94
|
+
offset = -top;
|
|
95
|
+
}
|
|
96
|
+
if (offset !== 0) {
|
|
97
|
+
y += offset;
|
|
98
|
+
this.$overlay.style.setProperty('--pg-overlay-menu-_y', `${y}px`);
|
|
99
|
+
}
|
|
92
100
|
}, {
|
|
93
101
|
root: null, // Defaults to the browser viewport
|
|
94
102
|
threshold: 1 // Triggers as soon as even 1 pixel enters or leaves
|