react-sticky
Advanced tools
Comparing version 4.0.1 to 4.0.2
@@ -37,6 +37,7 @@ 'use strict'; | ||
var pageY = window.pageYOffset; | ||
var origin = _this.getOrigin(pageY); | ||
var isSticky = _this.isSticky(pageY, _this.state.origin); | ||
var hasChanged = _this.state.isSticky !== isSticky; | ||
_this.setState({ isSticky: isSticky }); | ||
_this.setState({ isSticky: isSticky, origin: origin }); | ||
_this.context.container.updateOffset(isSticky ? _this.state.height : 0); | ||
@@ -49,3 +50,3 @@ | ||
var height = _reactDom2.default.findDOMNode(_this).getBoundingClientRect().height; | ||
var origin = _this.refs.placeholder.getBoundingClientRect().top + window.pageYOffset; | ||
var origin = _this.getOrigin(window.pageYOffset); | ||
_this.setState({ height: height, origin: origin }); | ||
@@ -79,2 +80,7 @@ }; | ||
}, { | ||
key: 'getOrigin', | ||
value: function getOrigin(pageY) { | ||
return this.refs.placeholder.getBoundingClientRect().top + pageY; | ||
} | ||
}, { | ||
key: 'update', | ||
@@ -84,3 +90,3 @@ value: function update() { | ||
var pageY = window.pageYOffset; | ||
var origin = this.refs.placeholder.getBoundingClientRect().top + pageY; | ||
var origin = this.getOrigin(pageY); | ||
var isSticky = this.isSticky(pageY, origin); | ||
@@ -87,0 +93,0 @@ this.setState({ height: height, origin: origin, isSticky: isSticky }); |
{ | ||
"name": "react-sticky", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Sticky component for React", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -63,2 +63,3 @@ react-sticky [![Build Status](https://travis-ci.org/captivationsoftware/react-sticky.svg?branch=master)](https://travis-ci.org/captivationsoftware/react-sticky) | ||
``` | ||
Note that the calculation of the Sticky element's height does not currently take margins into account. If you have margins on this element it may result in unexpected behavior. | ||
@@ -65,0 +66,0 @@ ### `<StickyContainer />` Props |
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
27487
474
177