import { Gesture } from "react-native-gesture-handler"; import { type SharedValue } from "react-native-reanimated"; import type { ChartPadding } from "../draw/line"; /** Engine SharedValues the pinch-zoom gesture reads/writes. */ export interface PinchZoomEngineRefs { /** Visible-window width override in seconds, or `null` to follow `timeWindow`. */ viewWindow: SharedValue; /** Absolute right-edge time, or `null` to follow the live edge (shared with pan). */ viewEnd: SharedValue; /** Right-edge time the engine would use if following live (advances each frame). */ liveEdge: SharedValue; /** * Animating visible window width in seconds. Written directly during a pinch so * the displayed window tracks the fingers 1:1 (the frame-loop lerp toward * `timeWindow` would otherwise lag a fast pinch and the focal anchor would drift). */ displayWindow: SharedValue; /** Canvas width in px. */ canvasWidth: SharedValue; } /** The pinch state cleared by the public chart handle's `resetZoom()` method. */ export type PinchZoomResetRefs = Pick; /** * Clear the focal-anchored pinch overrides so the engine follows its configured * `timeWindow` and live edge again. Safe to call when the chart is already reset. */ export declare function resetPinchZoom({ viewWindow, viewEnd, }: PinchZoomResetRefs): void; export interface UsePinchZoomOptions { engine: PinchZoomEngineRefs; padding: ChartPadding; /** * Earliest selectable time (unix seconds) — typically the first data point / * candle. Caps how far the (now wider) window can pan back when zooming out. */ minTime: SharedValue; /** The configured `timeWindow` prop (seconds) — the anchor for the zoom bounds. */ timeWindow: number; /** Master switch. When false the gesture is disabled. */ enabled: boolean; /** Tightest window (max zoom-in), seconds. Default `timeWindow / 8`. */ minTimeWindow?: number; /** Widest window (max zoom-out), seconds. Default: the full data span, ≥ `timeWindow`. */ maxTimeWindow?: number; /** Worklet fired when a pinch activates — e.g. to clear a lingering crosshair. */ onZoomStart?: () => void; /** * Fraction of the visible window (0–1) the zoomed window may travel past the * data bounds — blank future space beyond the live edge, blank history before * the oldest point. `0` (default) keeps the classic hard stops. Shared with * {@link usePanScroll} (resolved from `timeScroll.overscroll`). */ overscroll?: number; } /** Clamp a window width to `[minWin, maxWin]`. */ export declare function clampWindow(win: number, minWin: number, maxWin: number): number; /** * Resolve the zoom bounds for a gesture. `maxWin` defaults to the data span but * never goes below the configured window (so you can always zoom back out to the * starting view); `minWin` defaults to an 8× zoom-in of the configured window. * Guards against an inverted range (min ≤ max). */ export declare function zoomWindowBounds(configWindow: number, span: number, minCfg: number | undefined, maxCfg: number | undefined): [number, number]; /** * Absolute time under a pixel x, given the visible window. Inverse of the chart's * time→x projection: `x = chartLeft + (t - winStart)/window * chartW`. */ export declare function focalTime(focalX: number, chartLeft: number, chartW: number, winStart: number, windowSecs: number): number; /** * The new right-edge time that keeps `focalT` pinned under `focalX` after the * window width changes to `newWindow` — i.e. zoom around the focal point. Derived * from the projection above by solving for the right edge (`winStart + window`): * the right edge sits `(fraction of the window to the right of the focal)` past * `focalT`. */ export declare function zoomViewEnd(focalT: number, focalX: number, chartLeft: number, chartW: number, newWindow: number): number; /** * Pinch-to-zoom the visible time window, anchored at the focal point between the * two fingers (the time under your fingers stays put). Writes `engine.viewWindow` * (the window width) and `engine.viewEnd` (the right edge, so the focal anchor * holds) — the symmetric counterpart of {@link usePanScroll}, which only moves the * right edge. Pinch is two-finger, so it composes with the one-finger pan/scrub * via `Gesture.Simultaneous`. * * Reaching the live edge resumes following (`viewEnd → null`); the zoom level * (`viewWindow`) is independent of scroll position and persists. */ export declare function usePinchZoom({ engine, padding, minTime, timeWindow, enabled, minTimeWindow, maxTimeWindow, onZoomStart, overscroll, }: UsePinchZoomOptions): ReturnType; //# sourceMappingURL=usePinchZoom.d.ts.map