intersection-events
Advanced tools
Comparing version 0.1.1 to 0.1.2
/*! | ||
* intersection-events v0.1.1 | ||
* intersection-events v0.1.2 | ||
* https://github.com/ko-yelie/intersection-events#readme | ||
@@ -16,16 +16,6 @@ * | ||
var MAX_THRESHOLD = 0.99; // 1 だとアニメーションが発火しない端末が出るのでそれを回避 | ||
var MAX_THRESHOLD = 0.99; // If it is 1, a device that will not fire an animation comes out, so avoid it. | ||
/** | ||
* Wrapper of IntersectionObserver | ||
* | ||
* @example | ||
* new IntersectionEvents('.js-target', { | ||
* onEnter: () => { | ||
* // 要素がウィンドウ内に入ったとき | ||
* }, | ||
* onLeave: () => { | ||
* // 要素がウィンドウ外に出たとき | ||
* } | ||
* }) | ||
*/ | ||
@@ -67,7 +57,7 @@ | ||
if (!el.isEnter && isEnter(entry)) { | ||
// 要素全体がウィンドウ内に入ったとき | ||
// enter | ||
el.isEnter = true; | ||
onEnter(); | ||
} else if (el.isEnter && isLeave(entry)) { | ||
// 要素全体がウィンドウ外に出たとき | ||
// leave | ||
el.isEnter = false; | ||
@@ -90,3 +80,3 @@ onLeave(); | ||
if (isOverEnter || isOverLeave) { | ||
// 要素の高さがウィンドウより大きいときは、 threshold をウィンドウ内に収まるように変更する | ||
// When the height of the element is larger than the window, change threshold so that it fits within the window. | ||
currentObserver = new IntersectionObserver(callback, { | ||
@@ -93,0 +83,0 @@ threshold: [isOverLeave ? leaveThreshold * rate : leaveThreshold, isOverEnter ? enterThreshold * rate : enterThreshold] |
/*! | ||
* intersection-events v0.1.1 | ||
* intersection-events v0.1.2 | ||
* https://github.com/ko-yelie/intersection-events#readme | ||
@@ -42,16 +42,6 @@ * | ||
var MAX_THRESHOLD = 0.99; // 1 だとアニメーションが発火しない端末が出るのでそれを回避 | ||
var MAX_THRESHOLD = 0.99; // If it is 1, a device that will not fire an animation comes out, so avoid it. | ||
/** | ||
* Wrapper of IntersectionObserver | ||
* | ||
* @example | ||
* new IntersectionEvents('.js-target', { | ||
* onEnter: () => { | ||
* // 要素がウィンドウ内に入ったとき | ||
* }, | ||
* onLeave: () => { | ||
* // 要素がウィンドウ外に出たとき | ||
* } | ||
* }) | ||
*/ | ||
@@ -93,7 +83,7 @@ | ||
if (!el.isEnter && isEnter(entry)) { | ||
// 要素全体がウィンドウ内に入ったとき | ||
// enter | ||
el.isEnter = true; | ||
onEnter(); | ||
} else if (el.isEnter && isLeave(entry)) { | ||
// 要素全体がウィンドウ外に出たとき | ||
// leave | ||
el.isEnter = false; | ||
@@ -116,3 +106,3 @@ onLeave(); | ||
if (isOverEnter || isOverLeave) { | ||
// 要素の高さがウィンドウより大きいときは、 threshold をウィンドウ内に収まるように変更する | ||
// When the height of the element is larger than the window, change threshold so that it fits within the window. | ||
currentObserver = new IntersectionObserver(callback, { | ||
@@ -119,0 +109,0 @@ threshold: [isOverLeave ? leaveThreshold * rate : leaveThreshold, isOverEnter ? enterThreshold * rate : enterThreshold] |
/*! | ||
* intersection-events v0.1.1 | ||
* intersection-events v0.1.2 | ||
* https://github.com/ko-yelie/intersection-events#readme | ||
@@ -4,0 +4,0 @@ * |
{ | ||
"name": "intersection-events", | ||
"moduleName": "IntersectionEvents", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Wrapper of IntersectionObserver", | ||
"main": "dist/intersection-events.es.js", | ||
"unpkg": "dist/intersection-events.iife.min.js", | ||
"files": [ | ||
"dist/" | ||
], | ||
"scripts": { | ||
"build": "bili" | ||
"build": "bili", | ||
"docs": "esdoc" | ||
}, | ||
@@ -17,3 +21,4 @@ "repository": { | ||
"IntersectionObserver", | ||
"scroll" | ||
"scroll", | ||
"es2015" | ||
], | ||
@@ -29,3 +34,6 @@ "author": "Ko.Yelie", | ||
"banner-package": "^0.1.0", | ||
"bili": "^3.0.15" | ||
"bili": "^3.0.15", | ||
"esdoc": "^1.0.4", | ||
"esdoc-standard-plugin": "^1.0.0", | ||
"marked": "^0.3.19" | ||
}, | ||
@@ -32,0 +40,0 @@ "dependencies": { |
# intersection-events | ||
Wrapper of IntersectionObserver | ||
Wrapper of [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) | ||
You can detect when elements **enter and leave** window. | ||
Less Size, Less Features | ||
## ES Modules | ||
[npm](https://www.npmjs.com/package/intersection-events) | ||
```sh | ||
npm i intersection-events | ||
``` | ||
[Docs](https://ko-yelie.github.io/intersection-events/class/src/index.js~IntersectionEvents.html) | ||
```js | ||
@@ -9,6 +23,6 @@ import IntersectionEvents from 'intersection-events' | ||
onEnter: () => { | ||
// when element enter the window | ||
// When the whole element enters window | ||
}, | ||
onLeave: () => { | ||
// when element leave the window | ||
// When the whole element leaves window | ||
} | ||
@@ -18,4 +32,6 @@ }) | ||
--- | ||
## CDN | ||
[Download](https://unpkg.com/intersection-events) (1.4 KB) | ||
```html | ||
@@ -27,6 +43,14 @@ <script src="https://unpkg.com/intersection-events"></script> | ||
new IntersectionEvents('.js-target', { | ||
onEnter: () => { | ||
// when element enter the window | ||
} | ||
onEnter: () => {} | ||
}) | ||
``` | ||
--- | ||
If you should support browsers that do not support IntersectionObserver, use [IntersectionObserver polyfill](https://github.com/w3c/IntersectionObserver/tree/master/polyfill). | ||
--- | ||
If you want more features, please consider other libraries. | ||
- [Scrollama](https://github.com/russellgoldenberg/scrollama) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54
10981
5
6
184