react-stickynode
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -49,3 +49,2 @@ /** | ||
var scrollDelta = 0; | ||
var scrollTop = -1; | ||
var win; | ||
@@ -59,3 +58,2 @@ var winHeight = -1; | ||
docBody = doc.body; | ||
scrollTop = docBody.scrollTop + docEl.scrollTop; | ||
winHeight = win.innerHeight || docEl.clientHeight; | ||
@@ -84,2 +82,4 @@ M = window.Modernizr; | ||
this.frozen = false; | ||
this.skipNextScrollEvent = false; | ||
this.scrollTop = -1; | ||
@@ -132,3 +132,3 @@ this.bottomBoundaryTarget; | ||
var rect = target.getBoundingClientRect(); | ||
return scrollTop + rect.bottom; | ||
return this.scrollTop + rect.bottom; | ||
} | ||
@@ -199,3 +199,3 @@ }, { | ||
var height = innerRect.height || innerRect.bottom - innerRect.top;; | ||
var outerY = outerRect.top + scrollTop; | ||
var outerY = outerRect.top + this.scrollTop; | ||
@@ -233,4 +233,10 @@ self.setState({ | ||
scrollTop = ae.scroll.top; | ||
this.updateInitialDimension(); | ||
if (this.scrollTop === ae.scroll.top) { | ||
// Scroll position hasn't changed, | ||
// do nothing | ||
this.skipNextScrollEvent = true; | ||
} else { | ||
this.scrollTop = ae.scroll.top; | ||
this.updateInitialDimension(); | ||
} | ||
} | ||
@@ -240,3 +246,5 @@ }, { | ||
value: function handleScroll(e, ae) { | ||
if (this.frozen) { | ||
// Scroll doesn't need to be handled | ||
if (this.skipNextScrollEvent) { | ||
this.skipNextScrollEvent = false; | ||
return; | ||
@@ -246,3 +254,3 @@ } | ||
scrollDelta = ae.scroll.delta; | ||
scrollTop = ae.scroll.top; | ||
this.scrollTop = ae.scroll.top; | ||
this.update(); | ||
@@ -270,4 +278,4 @@ } | ||
// on document from viewport. | ||
var top = scrollTop + self.state.top; | ||
var bottom = scrollTop + self.state.bottom; | ||
var top = this.scrollTop + self.state.top; | ||
var bottom = this.scrollTop + self.state.bottom; | ||
@@ -388,3 +396,3 @@ // There are 2 principles to make sure Sticky won't get wrong so much: | ||
// when mount, the scrollTop is not necessary on the top | ||
scrollTop = docBody.scrollTop + docEl.scrollTop; | ||
this.scrollTop = docBody.scrollTop + docEl.scrollTop; | ||
@@ -391,0 +399,0 @@ if (self.props.enabled) { |
{ | ||
"name": "react-stickynode", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A performant and comprehensive React sticky", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,4 +18,2 @@ # react-stickynode | ||
This is also inspired by [Steve Carlson](https://github.com/src-code). | ||
## Features | ||
@@ -22,0 +20,0 @@ |
Sorry, the diff of this file is not supported yet
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
43009
743
100