react-intersection-observer
Advanced tools
Comparing version 4.0.2 to 5.0.0
{ | ||
"name": "react-intersection-observer", | ||
"version": "4.0.2", | ||
"version": "5.0.0", | ||
"description": "Monitor if a component is inside the viewport, using IntersectionObserver API", | ||
"main": "lib/index.js", | ||
"main": "dist/react-intersection-observer.cjs.js", | ||
"jsnext:main": "dist/react-intersection-observer.esm.js", | ||
"module": "dist/react-intersection-observer.esm.js", | ||
"author": "Daniel Schmidt", | ||
"typings": "index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/thebuilder/react-intersection-observer" | ||
"url": "https://github.com/thebuilder/react-intersection-observer.git" | ||
}, | ||
@@ -21,8 +26,13 @@ "license": "MIT", | ||
"scripts": { | ||
"build": "rm -rf lib es && npm run build:lib && npm run build:flow", | ||
"build:lib": "babel src --out-dir lib --ignore __*,*.story.js,*.test.js", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"build": "rm -rf dist && npm run build:lib && npm run build:flow", | ||
"build:lib": "run-p rollup:*", | ||
"build:storybook": "build-storybook --output-dir example", | ||
"build:flow": "flow-copy-source -v src lib", | ||
"build:flow": "node scripts/create-flow", | ||
"dev": "concurrently -k -r 'jest --watch' 'npm run storybook'", | ||
"lint": "eslint {src,stories,tests}/. ", | ||
"rollup:es": "rollup -c --environment FORMAT:es", | ||
"rollup:cjs": "rollup -c --environment FORMAT:cjs", | ||
"rollup:umd": "rollup -c --environment FORMAT:umd", | ||
"rollup:umd.min": "rollup -c --environment MINIFY,FORMAT:umd", | ||
"precommit": "flow && lint-staged", | ||
@@ -33,3 +43,3 @@ "postcommit": "git update-index --again", | ||
"storybook": "start-storybook -p 9000", | ||
"test": "eslint {src,stories,tests}/. && jest" | ||
"test": "jest" | ||
}, | ||
@@ -63,3 +73,7 @@ "lint-staged": { | ||
"setupFiles": [ | ||
"<rootDir>/jest-setup.js" | ||
"<rootDir>/scripts/jest-setup.js" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"jest-setup.js" | ||
] | ||
@@ -74,9 +88,10 @@ }, | ||
"devDependencies": { | ||
"@storybook/addon-actions": "^3.4.3", | ||
"@storybook/addon-options": "^3.4.3", | ||
"@storybook/react": "^3.4.3", | ||
"@storybook/addon-actions": "^3.4.5", | ||
"@storybook/addon-options": "^3.4.5", | ||
"@storybook/react": "^3.4.5", | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.26.3", | ||
"babel-jest": "^22.4.3", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-react": "^6.24.1", | ||
@@ -86,8 +101,9 @@ "babel-preset-stage-2": "^6.24.1", | ||
"concurrently": "3.5.1", | ||
"coveralls": "^3.0.1", | ||
"enzyme": "^3.3.0", | ||
"enzyme-adapter-react-16": "^1.0.4", | ||
"enzyme-to-json": "^3.3.3", | ||
"enzyme-to-json": "^3.3.4", | ||
"eslint": "^4.19.1", | ||
"eslint-config-insilico": "^5.2.0", | ||
"flow-bin": "^0.71.0", | ||
"flow-bin": "^0.72.0", | ||
"flow-copy-source": "^1.3.0", | ||
@@ -98,2 +114,3 @@ "husky": "^0.14.3", | ||
"lint-staged": "^7.0.0", | ||
"npm-run-all": "^4.1.3", | ||
"prettier": "^1.12.1", | ||
@@ -103,4 +120,9 @@ "react": "^16.3.2", | ||
"react-test-renderer": "^16.3.2", | ||
"request": "~2.85.0" | ||
"rollup": "^0.59.1", | ||
"rollup-plugin-babel": "^3.0.3", | ||
"rollup-plugin-commonjs": "^9.1.0", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-replace": "^2.0.0", | ||
"rollup-plugin-uglify": "^4.0.0" | ||
} | ||
} |
@@ -1,7 +0,11 @@ | ||
# react-intersection-observer | ||
# react-intersection-observer <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/thebuilder/react-intersection-observer.svg)](https://greenkeeper.io/) | ||
[![Travis](https://travis-ci.org/thebuilder/react-intersection-observer.svg?branch=master)](https://travis-ci.org/thebuilder/react-intersection-observer) | ||
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
[![npm](https://img.shields.io/npm/v/react-intersection-observer.svg)](https://www.npmjs.com/package/react-intersection-observer) | ||
[![Build Status][travis-svg]][travis-url] | ||
[![Coverage Statu][coveralls-svg]][coveralls-url] | ||
[![dependency status][deps-svg]][deps-url] | ||
[![dev dependency status][dev-deps-svg]][dev-deps-url] | ||
[![License][license-image]][license-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
[![Greenkeeper badge][greenkeeper-svg]][greenkeeper-url] | ||
[![styled with prettier][prettier-svg]][prettier-url] | ||
@@ -28,2 +32,4 @@ React component that triggers a function when the component enters or leaves the | ||
> ⚠️You also want to add the [intersection-observer](https://www.npmjs.com/package/react-intersection-observer) polyfill for full browser support. Check out adding the [polyfill](#polyfill) for details about how you can include it. | ||
## Usage | ||
@@ -73,3 +79,3 @@ | ||
You can monitor the onChange method, and control the state in your own | ||
component. | ||
component. This works with plain children, child as function or render props. | ||
@@ -104,21 +110,24 @@ ```js | ||
## Usage in other projects | ||
## Scroll monitor | ||
### react-scroll-percentage | ||
This module is used in | ||
[react-scroll-percentage](https://github.com/thebuilder/react-scroll-percentage) | ||
to monitor the scroll position of elements in view. This module is also a great | ||
example of using `react-intersection-observer` as the basis for more complex | ||
needs. | ||
to monitor the scroll position of elements in view, useful for animating items as | ||
they become visible. This module is also a great example of using `react-intersection-observer` | ||
as the basis for more complex needs. | ||
## Polyfill for intersection-observer | ||
## Intersection Observer | ||
The component requires the [intersection-observer | ||
API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) | ||
to be available on the global namespace. At the moment you should include a | ||
polyfill to ensure support in all browsers. | ||
[Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) | ||
is the API is used to determine if an element is inside the viewport or not. Browser support is pretty good, but Safari is still missing support. | ||
> [Can i use intersectionobserver?](https://caniuse.com/#feat=intersectionobserver) | ||
### Polyfill | ||
You can import the | ||
[polyfill](https://yarnpkg.com/en/package/intersection-observer) directly or use | ||
a service like [polyfill.io](https://polyfill.io/v2/docs/) that can add it when | ||
[polyfill](https://www.npmjs.com/package/react-intersection-observer) directly or use | ||
a service like [polyfill.io](https://polyfill.io/v2/docs/) to add it when | ||
needed. | ||
@@ -165,1 +174,20 @@ | ||
``` | ||
[package-url]: https://npmjs.org/package/react-intersection-observer | ||
[npm-version-svg]: http://versionbadg.es/thebuilder/react-intersection-observer.svg | ||
[travis-svg]: https://travis-ci.org/thebuilder/react-intersection-observer.svg | ||
[travis-url]: https://travis-ci.org/thebuilder/react-intersection-observer | ||
[coveralls-svg]: https://coveralls.io/repos/github/thebuilder/react-intersection-observer/badge.svg?branch=master | ||
[coveralls-url]: https://coveralls.io/github/thebuilder/react-intersection-observer?branch=master | ||
[deps-svg]: https://david-dm.org/thebuilder/react-intersection-observer.svg | ||
[deps-url]: https://david-dm.org/thebuilder/react-intersection-observer | ||
[dev-deps-svg]: https://david-dm.org/thebuilder/react-intersection-observer/dev-status.svg | ||
[dev-deps-url]: https://david-dm.org/thebuilder/react-intersection-observer#info=devDependencies | ||
[license-image]: http://img.shields.io/npm/l/react-intersection-observer.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/react-intersection-observer.svg | ||
[downloads-url]: http://npm-stat.com/charts.html?package=react-intersection-observer | ||
[greenkeeper-svg]: https://badges.greenkeeper.io/thebuilder/react-intersection-observer.svg | ||
[greenkeeper-url]: https://greenkeeper.io/ | ||
[prettier-svg]: https://img.shields.io/badge/styled_with-prettier-ff69b4.svg | ||
[prettier-url]: https://github.com/prettier/prettier |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
48669
804
190
35
9
2
1