intersection-observer 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/intersection-observer.js +2 -2
- package/package.json +8 -8
package/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
**⚠️ This polyfill was originally hosted in the [IntersectionObserver spec](https://github.com/w3c/IntersectionObserver) repo. Refer to that repo for commit history.**
|
2
|
+
|
1
3
|
# `IntersectionObserver` polyfill
|
2
4
|
|
3
5
|
This library polyfills the native [`IntersectionObserver`](http://w3c.github.io/IntersectionObserver/) API in unsupporting browsers. See the [API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) for usage information.
|
@@ -61,16 +63,16 @@ There are, however, additional use cases that the default configuration will not
|
|
61
63
|
|
62
64
|
If you need to handle any of these use-cases, you can configure the polyfill to poll the document by setting the `POLL_INTERVAL` property. This can be set either globally or on a per-instance basis.
|
63
65
|
|
64
|
-
**Enabling polling for all
|
66
|
+
**Enabling polling for all instances:**
|
65
67
|
|
66
|
-
To enable polling for all
|
68
|
+
To enable polling for all instances, set a value for `POLL_INTERVAL` on the `IntersectionObserver` prototype:
|
67
69
|
|
68
70
|
|
69
71
|
```js
|
70
72
|
IntersectionObserver.prototype.POLL_INTERVAL = 100; // Time in milliseconds.
|
71
73
|
```
|
72
74
|
|
73
|
-
**Enabling polling for individual
|
75
|
+
**Enabling polling for individual instances:**
|
74
76
|
|
75
77
|
To enable polling on only specific instances, set a `POLL_INTERVAL` value on the instance itself:
|
76
78
|
|
@@ -94,7 +96,7 @@ var io = new IntersectionObserver(callback);
|
|
94
96
|
io.USE_MUTATION_OBSERVER = false;
|
95
97
|
```
|
96
98
|
|
97
|
-
This is recommended in cases where the DOM will update frequently but you know those updates will have no
|
99
|
+
This is recommended in cases where the DOM will update frequently but you know those updates will have no effect on the position or your target elements.
|
98
100
|
|
99
101
|
|
100
102
|
## iframe support
|
@@ -171,7 +173,7 @@ Legacy support is also possible in very old browsers by including a shim for ES5
|
|
171
173
|
<script src="https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver"></script>
|
172
174
|
```
|
173
175
|
|
174
|
-
With these polyfills, `IntersectionObserver` has been tested
|
176
|
+
With these polyfills, `IntersectionObserver` has been tested and known to work in the following browsers:
|
175
177
|
|
176
178
|
<table>
|
177
179
|
<tr>
|
@@ -210,4 +212,4 @@ With these polyfills, `IntersectionObserver` has been tested an known to work in
|
|
210
212
|
|
211
213
|
To run the test suite for the `IntersectionObserver` polyfill, open the [`intersection-observer-test.html`](./intersection-observer-test.html) page in the browser of your choice.
|
212
214
|
|
213
|
-
If you run the tests in a browser that
|
215
|
+
If you run the tests in a browser that supports `IntersectionObserver` natively, the tests will be run against the native implementation. If it doesn't, the tests will be run against the polyfill.
|
package/intersection-observer.js
CHANGED
@@ -821,8 +821,8 @@ function removeEvent(node, event, fn, opt_useCapture) {
|
|
821
821
|
if (typeof node.removeEventListener == 'function') {
|
822
822
|
node.removeEventListener(event, fn, opt_useCapture || false);
|
823
823
|
}
|
824
|
-
else if (typeof node.
|
825
|
-
node.
|
824
|
+
else if (typeof node.detachEvent == 'function') {
|
825
|
+
node.detachEvent('on' + event, fn);
|
826
826
|
}
|
827
827
|
}
|
828
828
|
|
package/package.json
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"name": "intersection-observer",
|
3
|
-
"version": "0.12.
|
3
|
+
"version": "0.12.2",
|
4
4
|
"description": "A polyfill for IntersectionObserver",
|
5
|
-
"main": "intersection-observer",
|
6
|
-
"repository": {
|
7
|
-
"type": "git",
|
8
|
-
"url": "git@github.com:w3c/IntersectionObserver.git"
|
9
|
-
},
|
10
5
|
"keywords": [
|
11
6
|
"Intersection",
|
12
7
|
"Observer"
|
13
8
|
],
|
9
|
+
"main": "intersection-observer.js",
|
14
10
|
"author": {
|
15
11
|
"name": "Philip Walton",
|
16
12
|
"email": "philip@philipwalton.com",
|
17
13
|
"url": "http://philipwalton.com"
|
18
14
|
},
|
19
|
-
"license": "
|
15
|
+
"license": "Apache-2.0",
|
16
|
+
"repository": {
|
17
|
+
"type": "git",
|
18
|
+
"url": "https://github.com/GoogleChromeLabs/intersection-observer.git"
|
19
|
+
},
|
20
20
|
"bugs": {
|
21
|
-
"url": "https://github.com/
|
21
|
+
"url": "https://github.com/GoogleChromeLabs/intersection-observer/issues"
|
22
22
|
}
|
23
23
|
}
|