Reputation: 13
I have the following problem:
https://www.npmjs.com/package/react-countup
The counter is working in the opposite direction. From bottom to top and not from top to bottom using the enableScrollSpy: boolean (Enables start animation when target is in view.)
My code:
<CountUp
className={styles.contadoresLine2}
end={4000}
enableScrollSpy="true"
duration={1}
separator={"."}
/>
Upvotes: 1
Views: 1747
Reputation: 2493
Currently react-countup
is having issues with the enableScrollSpy. A simple work around is to install react-visibility-sensor
and use like below.
import VisibilitySensor from 'react-visibility-sensor';
<CountUp end={400}>
{({ countUpRef, start }) => (
<VisibilitySensor onChange={start}>
<span ref={countUpRef} />
</VisibilitySensor>
)}
</CountUp>
https://github.com/glennreyes/react-countup/issues/699
Upvotes: 1