UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

25 lines (24 loc) 471 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.enqueueFocus = enqueueFocus; let rafId = 0; function enqueueFocus(el, options = {}) { const { preventScroll = false, cancelPrevious = true, sync = false } = options; if (cancelPrevious) { cancelAnimationFrame(rafId); } const exec = () => el?.focus({ preventScroll }); if (sync) { exec(); } else { rafId = requestAnimationFrame(exec); } }