diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 8b21002..b975c9b 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -1,23 +1,8 @@ +import { type AnchorPositioningPolyfillOptions } from '../polyfill.ts'; + export {}; declare global { - interface AnchorPositioningPolyfillOptions { - // Whether to use `requestAnimationFrame()` when updating target elements’ - // positions - useAnimationFrame?: boolean; - - // An array of explicitly targeted elements to polyfill - elements?: HTMLElement[]; - - // Whether to exclude elements with eligible inline styles. When not defined - // or set to `false`, the polyfill will be applied to all elements that have - // eligible inline styles, regardless of whether the `elements` option is - // defined. When set to `true`, elements with eligible inline styles listed - // in the `elements` option will still be polyfilled, but no other elements - // in the document will be implicitly polyfilled. - excludeInlineStyles?: boolean; - } - interface Window { UPDATE_ANCHOR_ON_ANIMATION_FRAME?: boolean; ANCHOR_POSITIONING_POLYFILL_OPTIONS?: AnchorPositioningPolyfillOptions; diff --git a/src/polyfill.ts b/src/polyfill.ts index b5f9200..b4aa1eb 100644 --- a/src/polyfill.ts +++ b/src/polyfill.ts @@ -443,6 +443,23 @@ async function position(rules: AnchorPositions, useAnimationFrame = false) { } } +export interface AnchorPositioningPolyfillOptions { + // Whether to use `requestAnimationFrame()` when updating target elements’ + // positions + useAnimationFrame?: boolean; + + // An array of explicitly targeted elements to polyfill + elements?: HTMLElement[]; + + // Whether to exclude elements with eligible inline styles. When not defined + // or set to `false`, the polyfill will be applied to all elements that have + // eligible inline styles, regardless of whether the `elements` option is + // defined. When set to `true`, elements with eligible inline styles listed + // in the `elements` option will still be polyfilled, but no other elements + // in the document will be implicitly polyfilled. + excludeInlineStyles?: boolean; +} + function normalizePolyfillOptions( useAnimationFrameOrOption: boolean | AnchorPositioningPolyfillOptions = {}, ) {