diff --git a/package.json b/package.json index ca1eba2..345892a 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,11 @@ "name": "@juggle/resize-observer", "version": "2.4.0", "description": "Polyfills the ResizeObserver API and supports box size options from the latest spec", + "type": "module", "main": "./lib/ResizeObserver.js", "module": "./lib/ResizeObserver.js", "source": "./lib/ResizeObserver.js", + "types": "./lib/ResizeObserver.d.ts", "files": [ "lib/**/*.{js,ts}" ], diff --git a/src/ResizeObserverController.ts b/src/ResizeObserverController.ts index 7e83083..f0f3e4a 100644 --- a/src/ResizeObserverController.ts +++ b/src/ResizeObserverController.ts @@ -11,6 +11,7 @@ import { hasSkippedObservations } from './algorithms/hasSkippedObservations'; import { deliverResizeLoopError } from './algorithms/deliverResizeLoopError'; import { broadcastActiveObservations } from './algorithms/broadcastActiveObservations'; import { gatherActiveObservationsAtDepth } from './algorithms/gatherActiveObservationsAtDepth'; +import { ResizeObserverBoxOptions } from './ResizeObserverBoxOptions'; const resizeObservers: ResizeObserverDetail[] = []; const observerMap = new Map(); @@ -64,7 +65,7 @@ class ResizeObserverController { if (observerMap.has(resizeObserver)) { const detail = observerMap.get(resizeObserver) as ResizeObserverDetail; if (getObservationIndex(detail.observationTargets, target) < 0) { - detail.observationTargets.push(new ResizeObservation(target, options && options.box)); + detail.observationTargets.push(new ResizeObservation(target, options && options.box as ResizeObserverBoxOptions)); updateCount(1); scheduler.schedule(); // Schedule next observation } diff --git a/src/ResizeObserverOptions.ts b/src/ResizeObserverOptions.ts index 3748888..1bdf30d 100644 --- a/src/ResizeObserverOptions.ts +++ b/src/ResizeObserverOptions.ts @@ -2,12 +2,12 @@ import { ResizeObserverBoxOptions } from './ResizeObserverBoxOptions'; /** * Options to be given to the resize observer, - * when oberving a new element. + * when observing a new element. * * https://drafts.csswg.org/resize-observer-1/#dictdef-resizeobserveroptions */ interface ResizeObserverOptions { - box: ResizeObserverBoxOptions | undefined; + box?: 'content-box' | 'border-box' | ResizeObserverBoxOptions; } export { ResizeObserverOptions };