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

Fixed issue with gutter width initialization #1181

Merged
merged 1 commit into from
Jan 16, 2019
Merged
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
21 changes: 16 additions & 5 deletions src/TimeGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export default class TimeGrid extends Component {
window.removeEventListener('resize', this.handleResize)

raf.cancel(this.rafHandle)

if (this.measureGutterAnimationFrameRequest) {
window.cancelAnimationFrame(this.measureGutterAnimationFrameRequest)
}
}

componentDidUpdate() {
Expand Down Expand Up @@ -145,7 +149,7 @@ export default class TimeGrid extends Component {
let { min, max, components, accessors, localizer } = this.props

const resources = this.memoizedResources(this.props.resources, accessors)
const groupedEvents = resources.groupEvents(events)
const groupedEvents = resources.groupEvents(events)

return resources.map(([id, resource], i) =>
range.map((date, jj) => {
Expand Down Expand Up @@ -277,11 +281,18 @@ export default class TimeGrid extends Component {
}

measureGutter() {
const width = getWidth(this.gutter)

if (width && this.state.gutterWidth !== width) {
this.setState({ gutterWidth: width })
if (this.measureGutterAnimationFrameRequest) {
window.cancelAnimationFrame(this.measureGutterAnimationFrameRequest)
}
this.measureGutterAnimationFrameRequest = window.requestAnimationFrame(
() => {
const width = getWidth(this.gutter)

if (width && this.state.gutterWidth !== width) {
this.setState({ gutterWidth: width })
}
}
)
}

applyScroll() {
Expand Down