Skip to content

Commit

Permalink
Minor improvements (#86)
Browse files Browse the repository at this point in the history
* add 'type' and 'types' field to package.json

* improve box option usage in TypeScript
  • Loading branch information
TremayneChrist authored Nov 30, 2019
1 parent 381268a commit 31a9b69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
],
Expand Down
3 changes: 2 additions & 1 deletion src/ResizeObserverController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/ResizeObserverOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit 31a9b69

Please sign in to comment.