jsonkao / react-scrollama

Simple scrollytelling with the IntersectionObserver in React.
https://jsonkao.github.io/react-scrollama
MIT License
388 stars 30 forks source link

Update from 2.2.10 to 2.2.12 throws TypeError: Failed to construct 'IntersectionObserver': The provided double value is non-finite. #57

Closed danieleguido closed 3 years ago

danieleguido commented 3 years ago

Hi, are there any specific updates related to the v2.2.12 ? I tried to migrate from 2.2.10 to 2.2.12 and my code doesn't work anymore with the prop progress:

             <Scrollama
                  onStepEnter={this.onStepEnter}
                  onStepExit={this.onStepExit}
                  progress
                  onStepProgress={this.onStepProgress}
                  offset={0.42}
                  threshold={0}
                >
danieleguido commented 3 years ago

Also, the example code is not working, too. Apparently the step state.offsetHeight is null and get updated only after. I made the example code working by changing threshold options at #L194:

const options = {
         rootMargin: `${marginTop}px 0px ${marginBottom}px 0px`,
-        threshold: this.createThreshold(step.state.offsetHeight),
+        threshold: this.createThreshold(step.state.offsetHeight ?? 1),
       };