/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Where an element lands when it is moved, resized or drawn on a scale (#825, * #1148). This is pure arithmetic, shared by the pointer, the keyboard and the * tests of every canvas whose elements move along an axis: Plan's canvas, and * the Calendar's views. * * An element moves by whole UNITS: the buckets the pointer crossed since the * press (the bucket it is over, less the bucket it was grabbed in), or under * Shift one finer unit, the scale's `fineUnit` (a day under a week, month, * quarter or year; an hour under a day; fifteen minutes under an hour). A * scale whose bucket is its step has no finer unit, so Shift changes nothing * there. Both ends shift by the same amount, so an element keeps its place in * its bucket and its length: by the calendar on a time scale (a month on from * the 31st lands on a shorter month's last day), by the step on a number axis, * and by position on a list, where the whole element stays inside the list. * * A resize moves one end, never past the other: an element keeps at least one * unit (where an end names the last bucket it covers, one bucket). An element * drawn across empty time takes the units from the press to the pointer, at * least one. * * The rest of a drag is the drag layer's (east-ui-components, #608), which * every canvas rides: the 4px before it starts, Escape, the ghost and its * caption, and the target's refusal, asked where the drag rests and again of * the drop. * * @packageDocumentation */ import { type Scale } from "./scale.js"; /** An element's extent: a span's two ends, or a point element's instant twice. */ export interface Span { readonly start: I; readonly end: I; } /** What a gesture moves: the whole element, or one of its ends. */ export type MoveMode = "move" | "start" | "end"; /** * Whether the scale has a unit finer than its bucket: a time scale does, and a * scale whose bucket is its step does not. * * @param scale - The scale * @returns Whether Shift moves by a finer unit */ export declare function hasFineUnit(scale: Scale): boolean; /** * How many units lie between the press and the pointer: whole buckets, or the * scale's finer units under Shift. * * @param scale - The scale * @param grabFrac - Where the element was pressed, as a window fraction * @param frac - Where the pointer is now * @param fine - Whether Shift is held * @returns The signed count of units */ export declare function unitsBetween(scale: Scale, grabFrac: number, frac: number, fine: boolean): number; /** * An element moved `k` units, both ends shifted alike. On a list the move * stops where the element's first or last end meets the list's edge. * * @param scale - The scale * @param span - The element's extent * @param k - The signed number of units * @param fine - Whether the unit is Shift's finer one * @returns The extent it lands at */ export declare function moveSpan(scale: Scale, span: Span, k: number, fine: boolean): Span; /** * An element resized: one end moved `k` units, never past the other, so it * keeps at least one unit (where an end names its last bucket, one bucket) — * or, an element shorter than one, its own length: a resize never lengthens it * while it shrinks it, nor moves an end against its step. * * @param scale - The scale * @param span - The element's extent * @param edge - The end that moves * @param k - The signed number of units * @param fine - Whether the unit is Shift's finer one * @returns The extent it takes */ export declare function resizeSpan(scale: Scale, span: Span, edge: "start" | "end", k: number, fine: boolean): Span; /** * Where a pointer gesture lands: the element moved, or one of its ends, by the * units between the press and the pointer. * * @param scale - The scale * @param span - The element's extent when it was pressed * @param mode - What the gesture moves * @param grabFrac - Where it was pressed, as a window fraction * @param frac - Where the pointer is now * @param fine - Whether Shift is held * @returns The proposed extent */ export declare function proposeAt(scale: Scale, span: Span, mode: MoveMode, grabFrac: number, frac: number, fine: boolean): Span; /** A keyboard carry's steps since its element was picked up, a bucket each: of the whole element, and of each end. */ export interface CarrySteps { /** The whole element's. */ readonly move: number; /** Its start's. */ readonly start: number; /** Its end's. */ readonly end: number; } /** No steps yet. */ export declare const NO_STEPS: CarrySteps; /** * Where a keyboard carry's steps land, counted from the element as it was * picked up: moved by its whole steps, then each end by its own. Steps taken * back land it where it began. * * @param scale - The scale * @param span - The element's extent as it was picked up * @param steps - The steps since * @returns The proposed extent */ export declare function stepSpan(scale: Scale, span: Span, steps: CarrySteps): Span; /** * The extent a drag across empty time draws: from the unit under the press to * the unit under the pointer, both whole, whichever way the drag went, and at * least one unit. A unit is a bucket, or the scale's finer unit under Shift * (`fine`): a calendar's time grid, its buckets hours, draws in quarter hours. * Either end stays inside the units the scale covers. * * @param scale - The scale * @param pressFrac - Where the drag was pressed, as a window fraction * @param frac - Where the pointer is now * @param fine - Whether to draw in the finer unit * @returns The extent the drag draws */ export declare function drawSpan(scale: Scale, pressFrac: number, frac: number, fine: boolean): Span; /** * An extent as window fractions, clamped to the window: where a landing band * or a ghost draws it. * * @param scale - The scale * @param span - The extent * @returns Its left and right edges, 0–1 */ export declare function spanFracs(scale: Scale, span: Span): { left: number; right: number; }; //# sourceMappingURL=drag.d.ts.map