(props: {
isOpen: Accessor<boolean>
setIsOpen: (isOpen: boolean) => void
})
| 6 | createSignal, |
| 7 | flush, |
| 8 | onCleanup, |
| 9 | } from 'solid-js' |
| 10 | import { createDevtoolsSettings } from '../context/use-devtools-context' |
| 11 | import { createStyles } from '../styles/use-styles' |
| 12 | import { |
| 13 | HOT_CORNER_HOLD_MS, |
| 14 | HOT_CORNER_SNAP, |
| 15 | TRIGGER_EDGE_TAB_LENGTH, |
| 16 | TRIGGER_EDGE_TAB_PAD, |
| 17 | TRIGGER_TOOLTIP_MS, |
| 18 | } from '../utils/constants' |
| 19 | import { nativeListener } from '../utils/native-listener' |
| 20 | import { TanStackTriggerMark } from './tanstack-trigger-mark' |
| 21 | import type { Accessor } from 'solid-js' |
| 22 | import type { |
| 23 | TriggerCoords, |
| 24 | TriggerCorner, |
| 25 | TriggerEdge, |
| 26 | } from '../context/devtools-store' |
| 27 | |
| 28 | // --- Throw physics (pure, unit-tested in trigger.test.tsx) --- |
| 29 | const FRICTION = 0.95 // velocity retained each frame |
| 30 | const RESTITUTION = 0.5 // velocity retained after a wall bounce |
| 31 | const MIN_SPEED = 0.1 // px/frame below which the throw stops |
| 32 | const DRAG_THRESHOLD = 4 // px of movement before a press counts as a drag |
| 33 | const DIRECTION_DEADZONE = 8 // px below which a nudge has no directional intent |
| 34 | const DIRECTION_AXIS_RATIO = 0.5 // an axis only reads as intent at half the dominant one |
| 35 | const PADDING_RATIO = 0.5 // matches size[2] = --tsrd-font-size * 0.5 |
| 36 | |
| 37 | type Bounds = { minX: number; minY: number; maxX: number; maxY: number } |
| 38 | |
| 39 | // The visible viewport without scrollbars. `innerWidth`/`innerHeight` include |
| 40 | // them, which put the trigger under a page scrollbar. Falls back to the inner |
| 41 | // size where the root reports no layout (jsdom). |
| 42 | const viewportWidth = () => |
| 43 | document.documentElement.clientWidth || window.innerWidth |
| 44 | const viewportHeight = () => |
| 45 | document.documentElement.clientHeight || window.innerHeight |
| 46 | |
| 47 | export const clamp = (value: number, min: number, max: number) => |
| 48 | Math.max(min, Math.min(max, value)) |
| 49 | |
| 50 | export const cornerAt = ( |
| 51 | { x, y }: TriggerCoords, |
| 52 | b: Bounds, |
| 53 | snap = HOT_CORNER_SNAP, |
no test coverage detected