MCPcopy Create free account
hub / github.com/TanStack/devtools / Trigger

Function Trigger

packages/devtools/src/components/trigger.tsx:8–50  ·  view source on GitHub ↗
(props: {
  isOpen: Accessor<boolean>
  setIsOpen: (isOpen: boolean) => void
})

Source from the content-addressed store, hash-verified

6 createSignal,
7 flush,
8 onCleanup,
9} from 'solid-js'
10import { createDevtoolsSettings } from '../context/use-devtools-context'
11import { createStyles } from '../styles/use-styles'
12import {
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'
19import { nativeListener } from '../utils/native-listener'
20import { TanStackTriggerMark } from './tanstack-trigger-mark'
21import type { Accessor } from 'solid-js'
22import type {
23 TriggerCoords,
24 TriggerCorner,
25 TriggerEdge,
26} from '../context/devtools-store'
27
28// --- Throw physics (pure, unit-tested in trigger.test.tsx) ---
29const FRICTION = 0.95 // velocity retained each frame
30const RESTITUTION = 0.5 // velocity retained after a wall bounce
31const MIN_SPEED = 0.1 // px/frame below which the throw stops
32const DRAG_THRESHOLD = 4 // px of movement before a press counts as a drag
33const DIRECTION_DEADZONE = 8 // px below which a nudge has no directional intent
34const DIRECTION_AXIS_RATIO = 0.5 // an axis only reads as intent at half the dominant one
35const PADDING_RATIO = 0.5 // matches size[2] = --tsrd-font-size * 0.5
36
37type 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).
42const viewportWidth = () =>
43 document.documentElement.clientWidth || window.innerWidth
44const viewportHeight = () =>
45 document.documentElement.clientHeight || window.innerHeight
46
47export const clamp = (value: number, min: number, max: number) =>
48 Math.max(min, Math.min(max, value))
49
50export const cornerAt = (
51 { x, y }: TriggerCoords,
52 b: Bounds,
53 snap = HOT_CORNER_SNAP,

Callers 1

convertTriggerFunction · 0.85

Calls 3

createDevtoolsSettingsFunction · 0.90
createStylesFunction · 0.90
isOpenMethod · 0.80

Tested by

no test coverage detected