tangled
alpha
login
or
join now
olaren.dev
/
pdsls
forked from
pds.ls/pdsls
0
fork
atom
atmosphere explorer
0
fork
atom
overview
issues
pulls
pipelines
fix dropdown zoom position
handle.invalid
1 month ago
801d882d
6d3eb2cb
verified
This commit was signed with the committer's
known signature
.
handle.invalid
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+13
-2
1 changed file
expand all
collapse all
unified
split
src
components
dropdown.tsx
+13
-2
src/components/dropdown.tsx
···
104
104
const ctx = useContext(MenuContext);
105
105
const [menu, setMenu] = createSignal<HTMLDivElement>();
106
106
const [menuButton, setMenuButton] = createSignal<HTMLButtonElement>();
107
107
-
const [buttonRect, setButtonRect] = createSignal<DOMRect>();
107
107
+
const [buttonRect, setButtonRect] = createSignal<{ bottom: number; right: number }>();
108
108
109
109
const clickEvent = (event: MouseEvent) => {
110
110
const target = event.target as Node;
···
113
113
114
114
const updatePosition = () => {
115
115
const rect = menuButton()?.getBoundingClientRect();
116
116
-
if (rect) setButtonRect(rect);
116
116
+
if (rect) {
117
117
+
const isTouchDevice = window.matchMedia("(hover: none)").matches;
118
118
+
const vv = isTouchDevice ? window.visualViewport : null;
119
119
+
setButtonRect({
120
120
+
bottom: rect.bottom + (vv?.offsetTop ?? 0),
121
121
+
right: rect.right + (vv?.offsetLeft ?? 0),
122
122
+
});
123
123
+
}
117
124
};
118
125
119
126
onMount(() => {
120
127
window.addEventListener("click", clickEvent);
121
128
window.addEventListener("scroll", updatePosition, true);
122
129
window.addEventListener("resize", updatePosition);
130
130
+
window.visualViewport?.addEventListener("resize", updatePosition);
131
131
+
window.visualViewport?.addEventListener("scroll", updatePosition);
123
132
});
124
133
125
134
onCleanup(() => {
126
135
window.removeEventListener("click", clickEvent);
127
136
window.removeEventListener("scroll", updatePosition, true);
128
137
window.removeEventListener("resize", updatePosition);
138
138
+
window.visualViewport?.removeEventListener("resize", updatePosition);
139
139
+
window.visualViewport?.removeEventListener("scroll", updatePosition);
129
140
});
130
141
131
142
return (