Skip to content

Commit

Permalink
Merge pull request #265 from oddbird/hotfix-types
Browse files Browse the repository at this point in the history
Export new AnchorPositioningPolyfillOptions type
  • Loading branch information
jgerigmeyer authored Oct 16, 2024
2 parents d1d1285 + 4eee237 commit 9b0440e
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 9b0440e

Please sign in to comment.