react-scroll-parallax
Advanced tools
Comparing version 2.0.6 to 2.1.0
@@ -66,4 +66,4 @@ "use strict"; | ||
function _addListeners() { | ||
viewEl.addEventListener('scroll', _handleScroll, supportsPassive ? { | ||
function _addListeners(el) { | ||
el.addEventListener('scroll', _handleScroll, supportsPassive ? { | ||
passive: true | ||
@@ -74,4 +74,4 @@ } : false); | ||
function _removeListeners() { | ||
viewEl.removeEventListener('scroll', _handleScroll, supportsPassive ? { | ||
function _removeListeners(el) { | ||
el.removeEventListener('scroll', _handleScroll, supportsPassive ? { | ||
passive: true | ||
@@ -82,3 +82,3 @@ } : false); | ||
_addListeners(); | ||
_addListeners(viewEl); | ||
@@ -249,2 +249,23 @@ _setViewSize(); | ||
}; | ||
this.updateScrollContainer = function (el) { | ||
// remove existing listeners with current el first | ||
_removeListeners(viewEl); | ||
viewEl = el; | ||
hasScrollContainer = !!el; | ||
view = new _View.View({ | ||
width: 0, | ||
height: 0, | ||
scrollContainer: el | ||
}); | ||
_setViewSize(); | ||
_addListeners(viewEl); | ||
_updateAllElements({ | ||
updateCache: true | ||
}); | ||
}; | ||
/** | ||
@@ -256,3 +277,3 @@ * Removes listeners, reset all styles then nullifies the global ParallaxController. | ||
this.destroy = function () { | ||
_removeListeners(); | ||
_removeListeners(viewEl); | ||
@@ -259,0 +280,0 @@ elements.forEach(function (element) { |
@@ -75,2 +75,9 @@ "use strict"; | ||
_createClass(ParallaxProvider, [{ | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate(prevProps) { | ||
if (prevProps.scrollContainer !== this.props.scrollContainer) { | ||
this.controller.updateScrollContainer(this.props.scrollContainer); | ||
} | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
@@ -77,0 +84,0 @@ value: function componentWillUnmount() { |
{ | ||
"name": "react-scroll-parallax", | ||
"version": "2.0.6", | ||
"version": "2.1.0", | ||
"description": "React components to create parallax scroll effects for banners, images or any other DOM elements.", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
71839
1253