Skip to content

Commit

Permalink
Export new AnchorPositioningPolyfillOptions type
Browse files Browse the repository at this point in the history
  • Loading branch information
jgerigmeyer committed Oct 16, 2024
1 parent e1075b0 commit 4eee237
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
17 changes: 17 additions & 0 deletions src/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
) {
Expand Down

0 comments on commit 4eee237

Please sign in to comment.