()
| 15 | ] |
| 16 | |
| 17 | export default function App() { |
| 18 | const [activeIndex, setActiveIndex] = React.useState(0) |
| 19 | const springApi = useSpringRef() |
| 20 | |
| 21 | const transitions = useTransition(activeIndex, { |
| 22 | from: { |
| 23 | clipPath: 'polygon(0% 0%, 0% 100%, 0% 100%, 0% 0%)', |
| 24 | }, |
| 25 | enter: { |
| 26 | clipPath: 'polygon(0% 0%, 0% 100%, 100% 100%, 100% 0%)', |
| 27 | }, |
| 28 | leave: { |
| 29 | clipPath: 'polygon(100% 0%, 100% 100%, 100% 100%, 100% 0%)', |
| 30 | }, |
| 31 | onRest: (_springs, _ctrl, item) => { |
| 32 | if (activeIndex === item) { |
| 33 | setActiveIndex(activeIndex === IMAGES.length - 1 ? 0 : activeIndex + 1) |
| 34 | } |
| 35 | }, |
| 36 | exitBeforeEnter: true, |
| 37 | config: { |
| 38 | duration: 4000, |
| 39 | }, |
| 40 | delay: 1000, |
| 41 | ref: springApi, |
| 42 | }) |
| 43 | |
| 44 | const springs = useSpring({ |
| 45 | from: { |
| 46 | strokeDashoffset: 120, |
| 47 | }, |
| 48 | to: { |
| 49 | strokeDashoffset: 0, |
| 50 | }, |
| 51 | config: { |
| 52 | duration: 11000, |
| 53 | }, |
| 54 | loop: true, |
| 55 | ref: springApi, |
| 56 | }) |
| 57 | |
| 58 | React.useLayoutEffect(() => { |
| 59 | springApi.start() |
| 60 | }, [activeIndex, springApi]) |
| 61 | |
| 62 | return ( |
| 63 | <div className={styles.container}> |
| 64 | <div className={styles.container__inner}> |
| 65 | {transitions((springs, item) => ( |
| 66 | <animated.div className={styles.img__container} style={springs}> |
| 67 | <img src={IMAGES[item]} /> |
| 68 | </animated.div> |
| 69 | ))} |
| 70 | <div className={styles.ticker}> |
| 71 | <div /> |
| 72 | <animated.svg |
| 73 | width="40" |
| 74 | height="40" |
nothing calls this directly
no test coverage detected