react-intersection-observer
Advanced tools
Comparing version
@@ -61,3 +61,6 @@ 'use strict'; | ||
}, _this.handleChange = function (inView) { | ||
return _this.setState({ inView: inView }); | ||
_this.setState({ inView: inView }); | ||
if (_this.props.onChange) { | ||
_this.props.onChange(inView); | ||
} | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
@@ -67,9 +70,2 @@ } | ||
_createClass(Observer, [{ | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate(nextProps, nextState) { | ||
if (!!this.props.onChange && nextState !== this.state) { | ||
this.props.onChange(nextState.inView); | ||
} | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
@@ -76,0 +72,0 @@ value: function componentDidUpdate(prevProps, prevState) { |
{ | ||
"name": "react-intersection-observer", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Monitor if a component is inside the viewport, using IntersectionObserver API", | ||
@@ -65,8 +65,8 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@storybook/addon-actions": "^3.2.14", | ||
"@storybook/addon-options": "^3.2.14", | ||
"@storybook/react": "^3.2.14", | ||
"@storybook/addon-actions": "^3.3.12", | ||
"@storybook/addon-options": "^3.3.12", | ||
"@storybook/react": "^3.3.12", | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.25.0", | ||
"babel-jest": "^22.0.0", | ||
"babel-jest": "^22.1.0", | ||
"babel-preset-env": "^1.6.1", | ||
@@ -77,14 +77,14 @@ "babel-preset-react": "^6.24.1", | ||
"concurrently": "3.5.1", | ||
"enzyme": "^3.1.1", | ||
"enzyme": "^3.3.0", | ||
"enzyme-adapter-react-16": "^1.0.4", | ||
"enzyme-to-json": "^3.2.2", | ||
"eslint": "^4.10.0", | ||
"eslint-config-insilico": "^5.0.1", | ||
"flow-bin": "^0.62.0", | ||
"flow-copy-source": "^1.2.1", | ||
"enzyme-to-json": "^3.3.1", | ||
"eslint": "^4.17.0", | ||
"eslint-config-insilico": "^5.1.0", | ||
"flow-bin": "^0.64.0", | ||
"flow-copy-source": "^1.2.2", | ||
"husky": "^0.14.3", | ||
"intersection-observer": "^0.5.0", | ||
"jest": "^22.0.0", | ||
"lint-staged": "^6.0.0", | ||
"prettier": "^1.8.1", | ||
"jest": "^22.1.4", | ||
"lint-staged": "^6.1.0", | ||
"prettier": "^1.10.2", | ||
"react": "^16.2.0", | ||
@@ -91,0 +91,0 @@ "react-dom": "^16.2.0", |
@@ -53,8 +53,2 @@ // @flow | ||
componentWillUpdate(nextProps: Props, nextState: State) { | ||
if (!!this.props.onChange && nextState !== this.state) { | ||
this.props.onChange(nextState.inView) | ||
} | ||
} | ||
componentDidUpdate(prevProps: Props, prevState: State) { | ||
@@ -113,3 +107,8 @@ // If a IntersectionObserver option changed, reinit the observer | ||
handleChange = (inView: boolean) => this.setState({ inView }) | ||
handleChange = (inView: boolean) => { | ||
this.setState({ inView }) | ||
if (this.props.onChange) { | ||
this.props.onChange(inView) | ||
} | ||
} | ||
@@ -116,0 +115,0 @@ render() { |
@@ -160,2 +160,2 @@ // @flow | ||
destroy, | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42862
-0.8%561
-0.88%