joshwnj / joshwnj/react-visibility-sensor
containment prop doesn't seem to work with position absolute frame
- Dominant language
- JavaScript
- Stars
- 2.3k
- Forks
- 192
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to do an infinite scrolling pagination with the code below. I have a leftPanel component which is within a dashboard layout, so I thought by setting the containment will be fine. The problem is the onChange method called during the first render, I wonder what's wrong.
```
import { Component, PropTypes } from 'react'
// helpers
import { isEmpty, map, isEqual } from 'lodash'
import { routeUrl } from '~/utils/stringHelper'
// components
import { Link } from 'react-router'
import EmptyState from '~/components/common/EmptyState'
import Loading from '~/components/common/Loading'
import VisibilitySensor from 'react-visibility-sensor'
//styles
import './index.less'
class LeftPanel extends Component {
constructor() {
super()
this.state = {
page: 1,
noMore: false
}
}
componentWillReceiveProps(nextProps) {
if(isEmpty(nextProps.conversations)){
this.setState({ page: 1 })
}
}
componentDidMount() {
this.container = document.getElementById('subjects-container')
}
componentWillUnmount() {
}
handleLoaderInview = () => {
console.log('call') // triggered on the first time although the loader is not visible
if(this.props.conversations.length !== this.props.conversationsTotal) {
this.setState({
page: this.state.page + 1
}, () => {
console.log('fetchConversations')
this.props.fetchConversations(this.state.page)
})
}else{
this.setState({
noMore: true
})
}
}
render() {
const { openArchive } = this.props
return(
{(!this.props.isLoading && isEmpty(this.props.conversations)) && }
{!isEmpty(this.props.conversations) &&
map(this.props.conversations, (conversation, index) => (
))
}
{openArchive && }
)
}
}
export default LeftPanel
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.