resize-observer
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -7,2 +7,6 @@ # Change Log | ||
## [0.1.0] - 2018-03-25 | ||
### Fixed | ||
- `new ResizeObserver`, `ResizeObserver.prototype.observe`, and , `ResizeObserver.prototype.unobserve` should throw a `TypeError` when called with no arguments or the wrong argument type. | ||
## [0.0.4] - 2016-10-26 | ||
@@ -9,0 +13,0 @@ ### Fixed |
{ | ||
"name": "resize-observer", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "An implementation and polyfill of the Resize Observer draft.", | ||
@@ -5,0 +5,0 @@ "main": "resize-observer.js", |
# resize-observer | ||
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![NPM Version][npm-image]][npm-url] | ||
This library aims to be an implementation and polyfill of the | ||
This library aims to be a faithful implementation and polyfill of the | ||
[Resize Observer draft](https://wicg.github.io/ResizeObserver/). | ||
@@ -12,2 +12,36 @@ | ||
[coveralls-image]: https://coveralls.io/repos/github/pelotoncycle/resize-observer/badge.svg?branch=master | ||
[coveralls-url]: https://coveralls.io/github/pelotoncycle/resize-observer?branch=master | ||
[coveralls-url]: https://coveralls.io/github/pelotoncycle/resize-observer?branch=master | ||
[npm-image]: https://img.shields.io/npm/v/resize-observer.svg | ||
[npm-url]: https://www.npmjs.com/package/resize-observer | ||
# Installation | ||
`resize-observer` is available on NPM and Yarn: | ||
``` | ||
npm install resize-observer | ||
``` | ||
``` | ||
yarn add resize-observer | ||
``` | ||
# Setup | ||
`resize-observer` installs itself as `window.ResizeObserver` when it is required or otherwise put on the page: | ||
``` | ||
require('resize-observer'); | ||
const ro = new window.ResizeObserver(); | ||
``` | ||
``` | ||
<script src="/path/to/resize-observer.js"></script> | ||
<script type="text/javascript"> | ||
const ro = new window.ResizeObserver(); | ||
</script> | ||
``` | ||
**NOTE**: this behavior (auto-installing) may change in a future version. |
@@ -12,2 +12,5 @@ (function(window, undefined) { | ||
function ResizeObserver(callback) { | ||
if (typeof callback !== 'function') { | ||
throw new TypeError(); | ||
} | ||
document.resizeObservers.push(this); | ||
@@ -20,2 +23,5 @@ this.__callback = callback; | ||
ResizeObserver.prototype.observe = function(target) { | ||
if (!(target instanceof window.Element)) { | ||
throw new TypeError(); | ||
} | ||
var resizeObservationIndex = findTargetIndex(this.__observationTargets, target); | ||
@@ -31,2 +37,5 @@ if (resizeObservationIndex >= 0) { | ||
ResizeObserver.prototype.unobserve = function(target) { | ||
if (!(target instanceof window.Element)) { | ||
throw new TypeError(); | ||
} | ||
var resizeObservationIndex = findTargetIndex(this.__observationTargets, target); | ||
@@ -33,0 +42,0 @@ if (resizeObservationIndex === -1) { |
Sorry, the diff of this file is not supported yet
10096
152
47
7