react-scroll-rotate is a very simple react component that rotate children based on scroll poistion.
So for example, this "What?" title will look like this:
import { ScrollRotate } from 'react-scroll-rotate'; <Title> // Styled component for example What <ScrollRotate>?</ScrollRotate> </Title>
By default, without any prop, ScrollRotate will rotate based on Scroll top 1px=1deg
import { ScrollRotate } from 'react-scroll-rotate'; <ScrollRotate> <span>Rotate me</span> </ScrollRotate>
Use 'method' prop with 'perc' value to rotate based of scroll percantges
Use 'loops' prop to define how many rotations component will do during the scroll
Defualt is 1
import { ScrollRotate } from 'react-scroll-rotate'; <ScrollRotate method={"perc"}> <span>One loop</span </ScrollRotate> <ScrollRotate method={"perc"} loops={3}> <span>Three loops</span> </ScrollRotate>
Select target to control the component.
import { ScrollRotate } from 'react-scroll-rotate'; <ScrollRotate target={"target-element-id"}> <span>I will response to #target-element-id scroll</span> </ScrollRotate>
Use 'from' and 'To' props to adjust the range of the circle
Defaults: 0 - 360
import { ScrollRotate } from 'react-scroll-rotate'; <ScrollRotate from={90} to={270}> <span>From 90 to 270 Deg</span </ScrollRotate>
Use 'throttle' prop to invoke the update once in X seconds
Defaults: null
*Throttle is not used by default
*When you use 'throttle' prop you probably want to also add 'animationDuration' prop with +- same value
import { ScrollRotate } from 'react-scroll-rotate'; <ScrollRotate throttle={0.1}> <span>I will rotate every 0.1s</span </ScrollRotate>
Use 'animationDuration' props to set animation duration by Seconds
Defaults: 0.1
import { ScrollRotate } from 'react-scroll-rotate'; <ScrollRotate animationDuration={0.3}> <span>0.3s Animation duration</span </ScrollRotate>