@makolabs/ripple 0.0.1-dev.43 → 0.0.1-dev.44
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.
|
@@ -123,10 +123,21 @@
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
function handleClickOutside(event: MouseEvent) {
|
|
126
|
-
if
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
// Check if the click is inside the portal content
|
|
127
|
+
const portalContent = document.querySelector('.ripple-portal .portal-content');
|
|
128
|
+
|
|
129
|
+
// If the click is inside either the label (trigger) or the portal content, don't close
|
|
130
|
+
if (
|
|
131
|
+
(labelRef && labelRef.contains(event.target as Node)) ||
|
|
132
|
+
(portalContent && portalContent.contains(event.target as Node)) ||
|
|
133
|
+
!open
|
|
134
|
+
) {
|
|
135
|
+
return;
|
|
129
136
|
}
|
|
137
|
+
|
|
138
|
+
// Otherwise close the dropdown
|
|
139
|
+
open = false;
|
|
140
|
+
onclose();
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
function handleKeydown(event: KeyboardEvent) {
|
package/dist/utils/Portal.svelte
CHANGED
|
@@ -17,15 +17,17 @@
|
|
|
17
17
|
if (!ref || !target) return;
|
|
18
18
|
|
|
19
19
|
const { top, left, width, height } = target.getBoundingClientRect();
|
|
20
|
+
const scrollY = window.scrollY || document.documentElement.scrollTop;
|
|
21
|
+
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
20
22
|
|
|
21
23
|
// Set instant positioning without transitions for first render
|
|
22
24
|
if (!isPositioned) {
|
|
23
|
-
ref.style.position = '
|
|
25
|
+
ref.style.position = 'absolute';
|
|
24
26
|
ref.style.width = `${width}px`;
|
|
25
|
-
ref.style.
|
|
26
|
-
ref.style.top =
|
|
27
|
-
ref.style.left = '
|
|
28
|
-
ref.style.transform = `translate(${left}px, ${top}px)`;
|
|
27
|
+
ref.style.zIndex = '10000'; // Ensure the highest z-index
|
|
28
|
+
ref.style.top = `${height}px`; // Position below the target
|
|
29
|
+
ref.style.left = '0px';
|
|
30
|
+
ref.style.transform = `translate(${left + scrollX}px, ${top + scrollY}px)`;
|
|
29
31
|
ref.style.visibility = 'hidden'; // Keep hidden until fully positioned
|
|
30
32
|
|
|
31
33
|
// Wait for next frame to ensure positioning is applied before showing
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
});
|
|
40
42
|
} else {
|
|
41
43
|
// For subsequent updates, smoothly transition
|
|
42
|
-
ref.style.transform = `translate(${left}px, ${top}px)`;
|
|
44
|
+
ref.style.transform = `translate(${left + scrollX}px, ${top + scrollY}px)`;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -56,14 +58,23 @@
|
|
|
56
58
|
// Create portal container
|
|
57
59
|
portal = document.createElement('div');
|
|
58
60
|
portal.className = 'ripple-portal';
|
|
61
|
+
portal.style.position = 'fixed';
|
|
62
|
+
portal.style.zIndex = '10000'; // Ensure highest z-index
|
|
63
|
+
portal.style.top = '0';
|
|
64
|
+
portal.style.left = '0';
|
|
65
|
+
portal.style.width = '100%';
|
|
66
|
+
portal.style.pointerEvents = 'none'; // Allow clicking through the container but not its children
|
|
59
67
|
|
|
60
68
|
// Default to document.body if no target is provided
|
|
61
|
-
const targetElement =
|
|
69
|
+
const targetElement = document.body; // Always append to body for best visibility
|
|
62
70
|
targetElement.appendChild(portal);
|
|
63
71
|
|
|
64
72
|
// Move the content to the portal
|
|
65
73
|
portal.appendChild(ref);
|
|
66
74
|
|
|
75
|
+
// Allow pointer events on the content
|
|
76
|
+
ref.style.pointerEvents = 'auto';
|
|
77
|
+
|
|
67
78
|
// Initially hide the content
|
|
68
79
|
ref.style.opacity = '0';
|
|
69
80
|
|
|
@@ -95,4 +106,3 @@
|
|
|
95
106
|
<div class="portal-content" bind:this={ref}>
|
|
96
107
|
{@render children()}
|
|
97
108
|
</div>
|
|
98
|
-
|