Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scrollContainer should bypass overflow option #407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note

This project is now currently maintained by
This project is now currently maintained by
[@ameerthehacker](https://github.com/ameerthehacker), please reach out to him on any issues or help.

----
Expand All @@ -27,7 +27,7 @@ Lazyload your Components, Images or anything matters the performance.
> 2.0.0 is finally out, read [Upgrade Guide](https://github.com/twobin/react-lazyload/wiki/Upgrade-Guide), it's almost painless to upgrade!
> 3.0.0 fixes the findDomNode warning through usage of React ref, and the following are the changes you need to be aware of

* Now we have an extra div wrapping the lazy loaded component for the React ref to work
* Now we have an extra div wrapping the lazy loaded component for the React ref to work
* We can understand that it is an extra DOM node, and we are working to optimize that if possible
* It might break your UI or snapshot tests based on your usage
* To customize the styling to the extra div please refer [here](#classNamePrefix)
Expand Down Expand Up @@ -115,6 +115,9 @@ Type: String/DOM node Default: undefined

Pass a query selector string or DOM node. LazyLoad will attach to the window object's scroll events if no container is passed.

**NOTICE**
If scrollContainer is defined, the overflow option will be ignored.

### height

Type: Number/String Default: undefined
Expand Down Expand Up @@ -200,12 +203,12 @@ The `classNamePrefix` prop allows the user to supply their own custom class pref

These being:
# A wrapper div, which is present at all times (default )

### style

Type: Object Default: undefined

Similar to [classNamePrefix](#classNamePrefix), the `style` prop allows users to pass custom CSS styles to wrapper div.
Similar to [classNamePrefix](#classNamePrefix), the `style` prop allows users to pass custom CSS styles to wrapper div.

### wheel

Expand Down
2 changes: 1 addition & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class LazyLoad extends Component {
}
}

if (this.props.overflow) {
if (this.props.overflow && !scrollContainer) {
const parent = scrollParent(this.ref);
if (parent && typeof parent.getAttribute === 'function') {
const listenerCount = 1 + +parent.getAttribute(LISTEN_FLAG);
Expand Down
3 changes: 2 additions & 1 deletion test/specs/lazyload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ describe('LazyLoad', () => {
style={{ height: 10000 - 200 }}></div>
<LazyLoad
height={200}
scrollContainer="#scroll-container">
scrollContainer="#scroll-container"
overflow>
<div id="content" style={{ height: 200, width: '100%' }}></div>
</LazyLoad>
</div>
Expand Down