All files / hooks/use-scroll-lock/src types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                                                               
/**
 * Options for {@link useScrollLock}.
 */
export interface UseScrollLockOptions {
  /**
   * When `true`, this hook instance holds a scroll lock automatically for as
   * long as the value stays `true` — it locks on mount (or when the value flips
   * to `true`) and releases on unmount (or when it flips back to `false`).
   *
   * This is a convenience for the common "lock while the modal/drawer is open"
   * case. Leave it out (or pass `false`) to control locking imperatively via the
   * returned `lock()` / `unlock()`.
   *
   * When you use `enabled`, let it own the lock — don't also call `lock()` /
   * `unlock()` on the same instance, or the two owners will fight over the
   * shared lock counter.
   *
   * @default false
   */
  enabled?: boolean;
}
 
/**
 * Return value of {@link useScrollLock}.
 */
export interface UseScrollLockReturn {
  /**
   * Acquire a scroll lock for this hook instance. Idempotent — calling it again
   * while this instance already holds a lock is a no-op (it never double-counts
   * against the shared lock counter).
   */
  lock: () => void;
 
  /**
   * Release this instance's scroll lock. Idempotent — a no-op if this instance
   * does not currently hold a lock. The body is only restored once the **last**
   * outstanding lock (across all hook instances) is released.
   */
  unlock: () => void;
 
  /**
   * Whether **this** hook instance currently holds a lock. Note that the body
   * may still be locked by another instance even after this one unlocks; this
   * flag only reflects the current instance.
   */
  isLocked: boolean;
}