Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-lazy-load",
"version": "3.0.12",
"name": "react-lazy-load-zz",
"version": "3.0.14",
"description": "Simple lazy loading component built with react",
"main": "./lib/LazyLoad.js",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/LazyLoad.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export default class LazyLoad extends Component {
}

getEventNode() {
return parentScroll(findDOMNode(this));
const {wrapperClassName} = this.props;

return parentScroll(findDOMNode(this), wrapperClassName);
}

getOffset() {
Expand Down Expand Up @@ -147,6 +149,7 @@ LazyLoad.propTypes = {
PropTypes.number,
]),
onContentVisible: PropTypes.func,
wrapperClassName: PropTypes.string,
};

LazyLoad.defaultProps = {
Expand Down
8 changes: 6 additions & 2 deletions src/utils/parentScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const style = (element, prop) =>
const overflow = (element) =>
style(element, 'overflow') + style(element, 'overflow-y') + style(element, 'overflow-x');

const scrollParent = (element) => {
const hasClassName = (element, className) => element.classList.contains(className);

const hasValidOverflow = (element) => /(scroll|auto)/.test(overflow(element));

const scrollParent = (element, wrapperClassName) => {
if (!(element instanceof HTMLElement)) {
return window;
}
Expand All @@ -22,7 +26,7 @@ const scrollParent = (element) => {
break;
}

if (/(scroll|auto)/.test(overflow(parent))) {
if (hasClassName(parent, wrapperClassName) || hasValidOverflow(parent)) {
return parent;
}

Expand Down