@react-hive/honey-layout 14.2.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-hive/honey-layout",
3
- "version": "14.2.0",
3
+ "version": "16.0.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "react",
@@ -33,14 +33,15 @@
33
33
  "!dist/**/jest*"
34
34
  ],
35
35
  "peerDependencies": {
36
- "@react-hive/honey-style": "^3.0.0",
36
+ "@react-hive/honey-style": "^4.0.0",
37
37
  "react": "^19.0.0",
38
38
  "react-dom": "^19.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@floating-ui/dom": "1.7.5",
42
- "@floating-ui/react": "0.27.18",
43
- "@react-hive/honey-utils": "3.24.0",
41
+ "@floating-ui/dom": "1.7.6",
42
+ "@floating-ui/react": "0.27.19",
43
+ "@react-hive/honey-hooks": "1.0.0",
44
+ "@react-hive/honey-utils": "3.26.0",
44
45
  "csstype": "3.2.3",
45
46
  "highlight.js": "11.11.1",
46
47
  "lodash.merge": "4.6.2",
@@ -57,12 +58,12 @@
57
58
  "@types/lodash.merge": "4.6.9",
58
59
  "@types/lodash.throttle": "4.1.9",
59
60
  "@types/mdx": "2.0.13",
60
- "@types/node": "22.19.11",
61
+ "@types/node": "22.19.13",
61
62
  "@types/react": "^19.2.14",
62
63
  "@types/react-dom": "^19.2.3",
63
64
  "copy-webpack-plugin": "13.0.1",
64
65
  "css-loader": "7.1.4",
65
- "eslint": "10.0.0",
66
+ "eslint": "10.0.3",
66
67
  "eslint-plugin-react": "7.37.5",
67
68
  "html-webpack-plugin": "5.6.6",
68
69
  "husky": "9.1.7",
@@ -75,9 +76,9 @@
75
76
  "ts-node": "10.9.2",
76
77
  "tsx": "4.21.0",
77
78
  "typescript": "5.9.3",
78
- "typescript-eslint": "8.56.0",
79
- "webpack": "5.105.2",
80
- "webpack-cli": "6.0.1",
79
+ "typescript-eslint": "8.57.0",
80
+ "webpack": "5.105.4",
81
+ "webpack-cli": "7.0.1",
81
82
  "webpack-dev-server": "5.2.3"
82
83
  },
83
84
  "jest": {
@@ -1,179 +0,0 @@
1
- import type { InertiaOptions } from '@react-hive/honey-utils';
2
- /**
3
- * Configuration options for {@link useHoneyDecay}.
4
- */
5
- export interface UseHoneyDecayOptions extends Pick<InertiaOptions, 'friction' | 'minVelocityPxMs' | 'emaAlpha'> {
6
- /**
7
- * Initial numeric value from which inertial motion starts.
8
- *
9
- * This typically represents a translated position (e.g. scroll offset or `translateX` value),
10
- * but may be any bounded numeric domain.
11
- */
12
- initialValue: number;
13
- /**
14
- * Lower bound for the value (inclusive).
15
- *
16
- * Movement beyond this boundary is not permitted.
17
- */
18
- min: number;
19
- /**
20
- * Upper bound for the value (inclusive).
21
- *
22
- * Movement beyond this boundary is not permitted.
23
- */
24
- max: number;
25
- /**
26
- * Optional callback invoked exactly once when inertial motion terminates.
27
- *
28
- * Triggered when inertia ends due to:
29
- * - velocity decaying below `minVelocityPxMs`
30
- * - movement being blocked by bounds
31
- * - an explicit call to `stop()`
32
- *
33
- * Not invoked if inertia was never started.
34
- */
35
- onStop?: () => void;
36
- }
37
- /**
38
- * Public control API returned by {@link useHoneyDecay}.
39
- *
40
- * Exposes imperative controls for managing velocity-based inertial motion.
41
- */
42
- export interface UseHoneyDecayApi {
43
- /**
44
- * Current value produced by the decay simulation.
45
- *
46
- * This value updates over time while inertia is active
47
- * and always remains within the configured bounds.
48
- */
49
- value: number;
50
- /**
51
- * Indicates whether inertial motion is currently active.
52
- */
53
- isRunning: boolean;
54
- /**
55
- * Updates the hard bounds used by the decay simulation.
56
- *
57
- * This method is safe to call **at any time**, including while inertia is actively running.
58
- *
59
- * ### Behavior
60
- * - If the current value lies **within** the new bounds:
61
- * - bounds are updated
62
- * - inertia (if running) continues uninterrupted
63
- *
64
- * - If the current value lies **outside** the new bounds:
65
- * - the value is immediately clamped to the nearest boundary
66
- * - internal velocity is reset to `0`
67
- * - any active inertia is **terminated immediately**
68
- * - `onStop` is invoked exactly once (if inertia was active)
69
- *
70
- * This deterministic behavior mirrors native scroll engines and ensures:
71
- * - no overshoot
72
- * - no extra inertia frames
73
- * - consistent `onStop` semantics
74
- *
75
- * ### Intended usage
76
- * - Responding to layout or content changes
77
- * - Handling resize / orientation changes
78
- * - Updating overscroll or overflow limits dynamically
79
- *
80
- * ⚠️ This method should **not** be called from inside the RAF frame handler.
81
- *
82
- * @param min - New lower bound (inclusive)
83
- * @param max - New upper bound (inclusive)
84
- */
85
- setBounds: (min: number, max: number) => void;
86
- /**
87
- * Starts inertial motion from the current value using
88
- * the provided initial velocity.
89
- *
90
- * The sign of the velocity determines a direction:
91
- * - Positive → movement toward the upper bound
92
- * - Negative → movement toward the lower bound
93
- *
94
- * @param velocityPxMs - Initial velocity expressed in pixels per millisecond (`px/ms`).
95
- */
96
- start: (velocityPxMs: number) => void;
97
- /**
98
- * Immediately sets the value and starts inertial motion from that value in a single atomic operation.
99
- *
100
- * This is the preferred way to hand off from a gesture (e.g. drag end) to inertia, as it:
101
- * - avoids transient intermediate states
102
- * - guarantees correct value/velocity ordering
103
- * - ensures `onStop` semantics remain consistent
104
- *
105
- * @param value - Starting value for the inertia simulation
106
- * @param velocityPxMs - Initial velocity in pixels per millisecond (`px/ms`)
107
- */
108
- startFrom: (value: number, velocityPxMs: number) => void;
109
- /**
110
- * Immediately stops inertial motion.
111
- *
112
- * If inertia is currently active, this will:
113
- * - cancel the RAF loop
114
- * - reset internal velocity
115
- * - invoke `onStop` exactly once
116
- */
117
- stop: () => void;
118
- }
119
- /**
120
- * A bounded, velocity-based inertia (decay) hook built on top
121
- * of {@link useHoneyRafLoop} and {@link applyInertiaStep}.
122
- *
123
- * This hook models **momentum-driven motion** where:
124
- * - Motion starts with an initial velocity
125
- * - Velocity decays exponentially over time
126
- * - Movement is constrained by hard numeric bounds
127
- * - Inertia stops naturally when velocity becomes negligible
128
- *
129
- * Unlike spring-based motion, this hook has **no target value**.
130
- * Motion continues purely based on momentum until it decays
131
- * or is blocked by a boundary.
132
- *
133
- * ---
134
- *
135
- * ### Key characteristics
136
- * - Frame-rate independent (delta-time based)
137
- * - Deterministic and interruptible
138
- * - Direction-aware and bound-safe (no overshoot or jitter)
139
- * - Closely matches native scroll and drag inertia behavior
140
- *
141
- * ---
142
- *
143
- * ### Visibility behavior
144
- * This hook is a **simulation-based system**:
145
- * - Inertia automatically pauses when the document becomes hidden
146
- * - No time elapses while hidden
147
- * - Motion resumes only when explicitly restarted
148
- *
149
- * This behavior is inherited from {@link useHoneyRafLoop} and is intentional.
150
- *
151
- * ---
152
- *
153
- * ### Common use cases
154
- * - Scroll containers with momentum
155
- * - Drag-to-scroll interactions
156
- * - Carousels and sliders
157
- * - Timelines and scrubbers
158
- * - Kinetic panning and flinging
159
- *
160
- * ---
161
- *
162
- * @example
163
- * ```ts
164
- * const decay = useHoneyDecay({
165
- * initialValue: 0,
166
- * min: -maxOverflow,
167
- * max: 0,
168
- * });
169
- *
170
- * const onRelease = (velocityPxMs: number) => {
171
- * decay.start(velocityPxMs);
172
- * };
173
- *
174
- * return (
175
- * <div style={{ transform: `translateX(${decay.value}px)` }} />
176
- * );
177
- * ```
178
- */
179
- export declare const useHoneyDecay: ({ initialValue, min, max, friction, minVelocityPxMs, emaAlpha, onStop, }: UseHoneyDecayOptions) => UseHoneyDecayApi;
@@ -1,40 +0,0 @@
1
- import type { HoneyKeyboardEventCode } from '../types';
2
- export type UseHoneyDocumentOnKeyUpHandler = (keyCode: HoneyKeyboardEventCode, e: KeyboardEvent) => void;
3
- interface UseHoneyDocumentKeyUpOptions {
4
- /**
5
- * Whether the event listener should be active.
6
- *
7
- * @default true
8
- */
9
- enabled?: boolean;
10
- /**
11
- * Whether to call `preventDefault()` on matching keyup events.
12
- *
13
- * This is useful for suppressing default browser behavior (e.g., scrolling with Space key).
14
- *
15
- * @default true
16
- */
17
- preventDefault?: boolean;
18
- }
19
- /**
20
- * Hook for handling specific key up events on the `document` object.
21
- *
22
- * This hook adds a `keyup` event listener at the document level and triggers the provided `keyUpHandler`
23
- * when one of the specified `listenKeys` is released.
24
- *
25
- * @param onKeyUp - The callback function invoked when a matching key is released.
26
- * @param listenKeys - An array of key codes (`KeyboardEvent.code`) to listen for.
27
- * @param options - Optional configuration to control event behavior and listener activation.
28
- *
29
- * @example
30
- * ```tsx
31
- * useHoneyDocumentKeyUp(
32
- * (keyCode, event) => {
33
- * console.log('Key released:', keyCode);
34
- * },
35
- * ['Escape'],
36
- * );
37
- * ```
38
- */
39
- export declare const useHoneyDocumentKeyUp: (onKeyUp: UseHoneyDocumentOnKeyUpHandler, listenKeys: HoneyKeyboardEventCode[], { enabled, preventDefault }?: UseHoneyDocumentKeyUpOptions) => void;
40
- export {};
@@ -1,200 +0,0 @@
1
- import type { RefObject } from 'react';
2
- import type { Nullable } from '../types';
3
- /**
4
- * Invoked when a drag gesture is about to start.
5
- *
6
- * This handler is called on the initial pointer-down interaction
7
- * (mouse or touch) **before** drag tracking begins.
8
- *
9
- * It can be used to:
10
- * - Conditionally allow or block dragging
11
- * - Capture initial external state
12
- * - Cancel dragging based on application logic
13
- *
14
- * @template Element - The draggable element type.
15
- *
16
- * @param draggableElement - The element that will be dragged.
17
- * @param e - The initiating pointer event.
18
- *
19
- * @returns A promise resolving to:
20
- * - `true` to allow the drag to begin
21
- * - `false` to cancel the drag
22
- */
23
- export type UseHoneyDragOnStartHandler<Element extends HTMLElement> = (draggableElement: Element, e: MouseEvent | TouchEvent) => Promise<boolean>;
24
- /**
25
- * Context describing pointer movement during an active drag gesture.
26
- *
27
- * All values are expressed in **pixels** and are relative
28
- * to the drag start or previous frame as noted.
29
- */
30
- export interface UseHoneyDragOnMoveContext {
31
- /**
32
- * Horizontal delta since the previous move event.
33
- *
34
- * Positive values indicate movement to the right.
35
- */
36
- deltaX: number;
37
- /**
38
- * Vertical delta since the previous move event.
39
- *
40
- * Positive values indicate movement downward.
41
- */
42
- deltaY: number;
43
- /**
44
- * Total horizontal displacement from the drag start position.
45
- */
46
- distanceX: number;
47
- /**
48
- * Total vertical displacement from the drag start position.
49
- */
50
- distanceY: number;
51
- }
52
- /**
53
- * Handler invoked continuously while a drag gesture is active.
54
- *
55
- * This handler:
56
- * - Is created once per drag start
57
- * - Receives incremental movement data on each pointer move
58
- * - Can synchronously or asynchronously decide whether dragging continues
59
- *
60
- * Returning `false` from the move callback immediately terminates the drag.
61
- *
62
- * @template Element - The draggable element type.
63
- *
64
- * @param draggableElement - The element being dragged.
65
- *
66
- * @returns A function invoked on every pointer move, receiving
67
- * {@link UseHoneyDragOnMoveContext}, and resolving to:
68
- * - `true` to continue dragging
69
- * - `false` to stop dragging immediately
70
- */
71
- export type UseHoneyDragOnMoveHandler<Element extends HTMLElement> = (draggableElement: Element) => (context: UseHoneyDragOnMoveContext) => Promise<boolean>;
72
- /**
73
- * Context describing the final state of a completed drag gesture.
74
- *
75
- * This context exposes **release velocity**, which is suitable for
76
- * inertia, momentum, or decay-based motion systems.
77
- */
78
- interface UseHoneyDragOnEndContext {
79
- /**
80
- * Total horizontal displacement from drag start to release.
81
- */
82
- deltaX: number;
83
- /**
84
- * Total vertical displacement from drag start to release.
85
- */
86
- deltaY: number;
87
- /**
88
- * Horizontal release velocity in pixels per millisecond (`px/ms`).
89
- *
90
- * This value represents the **instantaneous velocity at release**
91
- * and is suitable for inertia or momentum-based motion.
92
- */
93
- velocityXPxMs: number;
94
- /**
95
- * Vertical release velocity in pixels per millisecond (`px/ms`).
96
- *
97
- * This value represents the **instantaneous velocity at release**
98
- * and is suitable for inertia or momentum-based motion.
99
- */
100
- velocityYPxMs: number;
101
- }
102
- /**
103
- * Invoked when a drag gesture ends.
104
- *
105
- * This handler is called when:
106
- * - The pointer is released
107
- * - The drag is programmatically terminated (unless explicitly skipped)
108
- *
109
- * It provides final displacement and **release velocity**, making it
110
- * ideal for triggering inertia or decay animations.
111
- *
112
- * @template Element - The draggable element type.
113
- *
114
- * @param context - Final drag metrics, including release velocity.
115
- * @param draggableElement - The element that was dragged.
116
- * @param e - The pointer event that finished the drag.
117
- *
118
- * @returns A promise that resolves when cleanup or follow-up logic completes.
119
- */
120
- export type UseHoneyDragOnEndHandler<Element extends HTMLElement> = (context: UseHoneyDragOnEndContext, draggableElement: Element, e: MouseEvent | TouchEvent) => Promise<void>;
121
- /**
122
- * Collection of handlers controlling the lifecycle of a drag gesture.
123
- *
124
- * Together, these handlers define:
125
- * - Whether dragging is allowed
126
- * - How movement is handled
127
- * - What happens when dragging ends
128
- */
129
- export interface UseHoneyDragHandlers<Element extends HTMLElement> {
130
- /**
131
- * Optional handler triggered when the drag operation starts.
132
- * This is useful for capturing the initial state or performing any setup actions before the drag starts.
133
- *
134
- * @param element - The element being dragged.
135
- *
136
- * @returns A boolean or Promise resolving to a boolean indicating if the drag should proceed.
137
- */
138
- onStartDrag?: UseHoneyDragOnStartHandler<Element>;
139
- /**
140
- * Required handler triggered continuously during the drag operation.
141
- * This handler is responsible for updating the drag state and typically tracks the element's movement.
142
- *
143
- * @param element - The element being dragged.
144
- *
145
- * @returns A boolean or Promise resolving to a boolean indicating whether the drag should continue.
146
- */
147
- onMoveDrag: UseHoneyDragOnMoveHandler<Element>;
148
- /**
149
- * Optional handler triggered when the drag operation ends.
150
- * This is commonly used for cleanup or finalizing the drag process.
151
- *
152
- * @param context - Contains information about the drag operation, such as distance and speed.
153
- * @param element - The element being dragged.
154
- *
155
- * @returns A Promise.
156
- */
157
- onEndDrag?: UseHoneyDragOnEndHandler<Element>;
158
- }
159
- /**
160
- * Configuration options controlling drag behavior.
161
- *
162
- * These options affect lifecycle handling and enable/disable logic,
163
- * but do not influence movement physics directly.
164
- */
165
- export interface UseHoneyDragOptions<Element extends HTMLElement> extends UseHoneyDragHandlers<Element> {
166
- /**
167
- * Controls whether the `onEndDrag` handler is skipped when the drag operation is forcibly stopped.
168
- * This can be useful when dragging is interrupted or terminated early due to movement restrictions.
169
- *
170
- * @default false
171
- */
172
- skipOnEndDragWhenStopped?: boolean;
173
- /**
174
- * Determines if the drag functionality is enabled or disabled.
175
- *
176
- * @default true
177
- */
178
- enabled?: boolean;
179
- }
180
- /**
181
- * Enables high-precision mouse and touch dragging for an element.
182
- *
183
- * This hook:
184
- * - Tracks pointer movement using `performance.now()`
185
- * - Computes **instantaneous release velocity** (px/ms)
186
- * - Emits deterministic drag lifecycle events
187
- * - Supports both mouse and touch input
188
- *
189
- * Architectural notes:
190
- * - Velocity is computed **during movement**, not at drag end
191
- * - Release velocity is suitable for inertia / decay systems
192
- * - No layout reads or writes are performed internally
193
- *
194
- * @template Element - The draggable HTML element type.
195
- *
196
- * @param draggableElementRef - Ref pointing to the draggable element.
197
- * @param options - Drag lifecycle handlers and configuration flags.
198
- */
199
- export declare const useHoneyDrag: <Element extends HTMLElement>(draggableElementRef: RefObject<Nullable<Element>>, { skipOnEndDragWhenStopped, enabled, onMoveDrag, onStartDrag, onEndDrag, }: UseHoneyDragOptions<Element>) => void;
200
- export {};
@@ -1,18 +0,0 @@
1
- import type { RefObject } from 'react';
2
- type UseHoneyLatest = {
3
- <T>(value: T): RefObject<T>;
4
- <T>(value: T | undefined): RefObject<T | undefined>;
5
- };
6
- /**
7
- * Stores the latest value in a stable ref.
8
- *
9
- * Guarantees that:
10
- * - `ref.current` always points to the latest value
11
- * - the ref object identity never changes
12
- *
13
- * Overload behavior:
14
- * - If a non-optional value is provided, `.current` is non-optional
15
- * - If an optional value is provided, `.current` is optional
16
- */
17
- export declare const useHoneyLatest: UseHoneyLatest;
18
- export {};
@@ -1,27 +0,0 @@
1
- import type { EffectCallback } from 'react';
2
- /**
3
- * A hook that invokes a callback function whenever the provided `state` value changes.
4
- *
5
- * This hook stores the previous value internally and performs a shallow comparison with the current value.
6
- * If a change is detected, it executes the `onChange` callback. If the callback returns a cleanup function,
7
- * it will be invoked before the next change or when the component unmounts, similar to standard `useEffect` behavior.
8
- *
9
- * @template T - The type of the state being observed.
10
- *
11
- * @param state - The value to monitor for changes. Can be of any type.
12
- * @param onChange - A function called whenever `state` changes. It may return a cleanup function.
13
- *
14
- * @returns void
15
- *
16
- * @example
17
- * ```ts
18
- * useHoneyOnChange(someValue, (newValue) => {
19
- * console.log('Value changed to:', newValue);
20
- *
21
- * return () => {
22
- * console.log('Cleanup for value:', newValue);
23
- * };
24
- * });
25
- * ```
26
- */
27
- export declare const useHoneyOnChange: <T>(state: T, onChange: (newState: T) => ReturnType<EffectCallback>) => void;
@@ -1,164 +0,0 @@
1
- interface UseHoneyRafFrameContext {
2
- /**
3
- * Immediately terminates the active `requestAnimationFrame` loop.
4
- *
5
- * This method is **safe to call synchronously from within the frame handler**
6
- * and is the **recommended mechanism** for ending frame-driven processes based on runtime conditions.
7
- *
8
- * Typical use cases:
9
- * - Inertia or momentum decay reaching a threshold
10
- * - Animation or transition completion
11
- * - Time- or state-based termination conditions
12
- */
13
- stop: () => void;
14
- }
15
- /**
16
- * Function invoked on every animation frame while the RAF loop is active.
17
- *
18
- * The handler is expected to be **side-effect driven** and may:
19
- * - Mutate refs
20
- * - Update React state
21
- * - Stop the RAF loop via `context.stop()`
22
- *
23
- * ⚠️ Referential stability
24
- * This handler **must be wrapped in `useCallback`** to avoid unnecessary
25
- * re-bindings and to ensure predictable behavior across renders.
26
- *
27
- * @param deltaTimeMs - Time delta in milliseconds since the previous frame.
28
- * This value is clamped to `maxDeltaMs` to prevent large
29
- * time steps caused by tab backgrounding, visibility changes,
30
- * or browser throttling.
31
- *
32
- * @param context - RAF lifecycle control context. See {@link UseHoneyRafFrameContext}.
33
- */
34
- export type UseHoneyRafOnFrameHandler = (deltaTimeMs: number, context: UseHoneyRafFrameContext) => void;
35
- /**
36
- * Configuration options for {@link useHoneyRafLoop}.
37
- */
38
- interface UseHoneyRafLoopOptions {
39
- /**
40
- * Automatically start the RAF loop on mount.
41
- *
42
- * This is useful for continuous loops (e.g. visualizers),
43
- * but should generally be disabled for gesture- or intent-driven animations.
44
- *
45
- * @default false
46
- */
47
- autoStart?: boolean;
48
- /**
49
- * Whether the RAF loop should automatically resume when the
50
- * document becomes visible again after being hidden.
51
- *
52
- * ⚠️ Important:
53
- * - Visibility changes will ALWAYS stop the RAF loop
54
- * - Resuming is **opt-in** and never happens implicitly
55
- *
56
- * This option should only be enabled for truly continuous
57
- * systems (e.g. game loops, live visualizations).
58
- *
59
- * It is intentionally disabled by default to avoid restarting
60
- * gesture-driven or state-sensitive animations with stale data.
61
- *
62
- * Requires `autoStart` to be enabled.
63
- *
64
- * @default false
65
- */
66
- resumeOnVisibility?: boolean;
67
- /**
68
- * Maximum allowed delta time between frames.
69
- *
70
- * This prevents physics, inertia, or animation logic from receiving large
71
- * time steps after backgrounding, tab switches, or frame drops.
72
- *
73
- * @default 32
74
- */
75
- maxDeltaMs?: number;
76
- /**
77
- * Optional error handler invoked when the RAF callback throws.
78
- *
79
- * When an error occurs:
80
- * - The RAF loop is immediately stopped
81
- * - `isRafLoopRunning` is set to `false`
82
- * - The error is passed to this handler
83
- *
84
- * @default undefined
85
- */
86
- onError?: (error: unknown) => void;
87
- }
88
- /**
89
- * Public control API returned by {@link useHoneyRafLoop}.
90
- */
91
- export interface HoneyRafLoopApi {
92
- /**
93
- * Indicates whether the RAF loop is currently running.
94
- */
95
- isRunning: boolean;
96
- /**
97
- * Starts the RAF loop.
98
- *
99
- * If the loop is already running, this call is ignored.
100
- */
101
- start: () => void;
102
- /**
103
- * Stops the RAF loop immediately.
104
- *
105
- * This method is safe to call:
106
- * - From user code
107
- * - From within the RAF frame handler
108
- */
109
- stop: () => void;
110
- }
111
- /**
112
- * A hook for running a controlled `requestAnimationFrame` loop.
113
- *
114
- * Features:
115
- * - Explicit RAF lifecycle control (`start` / `stop`)
116
- * - Delta time calculation with frame clamping
117
- * - Automatic cleanup on unmounting
118
- * - Conservative handling of tab visibility changes (mobile-safe)
119
- * - Safe error handling (stops loop on exception)
120
- *
121
- * Visibility behavior:
122
- * - The RAF loop is always stopped when the document becomes hidden
123
- * - Automatic resume is disabled by default and must be explicitly enabled
124
- *
125
- * This hook is designed for gesture handling, inertia, physics simulations,
126
- * and animation loops that must not trigger React re-renders on every frame.
127
- *
128
- * @param onFrame - Function invoked on each animation frame.
129
- * @param options - Optional configuration for the RAF loop.
130
- *
131
- * @returns Control helpers and RAF loop state.
132
- *
133
- * @example
134
- * ```ts
135
- * // Gesture-driven inertia (recommended usage)
136
- * // The RAF loop stops itself when motion decays.
137
- *
138
- * const velocityRef = useRef({ x: 12, y: 4 });
139
- *
140
- * const onFrame = useCallback<HoneyRafOnFrameHandler>(
141
- * (dtMs, { stop }) => {
142
- * velocityRef.current.x *= 0.94;
143
- * velocityRef.current.y *= 0.94;
144
- *
145
- * setPosition(p => ({
146
- * x: p.x + velocityRef.current.x,
147
- * y: p.y + velocityRef.current.y,
148
- * }));
149
- *
150
- * if (
151
- * Math.abs(velocityRef.current.x) < 0.1 &&
152
- * Math.abs(velocityRef.current.y) < 0.1
153
- * ) {
154
- * stop(); // terminate RAF loop
155
- * }
156
- * },
157
- * [],
158
- * );
159
- *
160
- * useHoneyRafLoop(onFrame);
161
- * ```
162
- */
163
- export declare const useHoneyRafLoop: (onFrame: UseHoneyRafOnFrameHandler, { autoStart, resumeOnVisibility, maxDeltaMs, onError, }?: UseHoneyRafLoopOptions) => HoneyRafLoopApi;
164
- export {};