From 7781e6b5d82ac048b5cbbb1e6bae563ce1b34200 Mon Sep 17 00:00:00 2001 From: Jan Bevers Date: Wed, 16 Jan 2019 19:43:06 +0100 Subject: [PATCH] Fixed issue with gutter width initialization --- src/TimeGrid.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/TimeGrid.js b/src/TimeGrid.js index 7ab99fc26..c3ba681d3 100644 --- a/src/TimeGrid.js +++ b/src/TimeGrid.js @@ -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() { @@ -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) => { @@ -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() {