add isPointNotInRect

This commit is contained in:
thislight 2024-12-01 22:50:29 +08:00
parent d6c717a73e
commit c260027c9c
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
3 changed files with 9 additions and 12 deletions

View file

@ -19,6 +19,7 @@ import { animateSlideInFromRight, animateSlideOutToRight } from "./anim";
import { ANIM_CURVE_DECELERATION, ANIM_CURVE_STD } from "~material/theme";
import { makeEventListener } from "@solid-primitives/event-listener";
import { useWindowSize } from "@solid-primitives/resize-observer";
import { isPointNotInRect } from "./dom";
export type StackedRouterProps = Omit<RouterProps, "url">;
@ -173,12 +174,7 @@ function onDialogClick(
) {
if (event.target !== event.currentTarget) return;
const rect = event.currentTarget.getBoundingClientRect();
const isNotInDialog =
event.clientY < rect.top ||
event.clientY > rect.bottom ||
event.clientX < rect.left ||
event.clientX > rect.right;
if (isNotInDialog) {
if (isPointNotInRect(rect, event.clientX, event.clientY)) {
onClose();
}
}