You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cursor.tsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React from 'react'
  2. import styled from 'styles'
  3. import { motion } from 'framer-motion'
  4. export default function Cursor({
  5. color = 'dodgerblue',
  6. duration = 0,
  7. bufferedXs = [],
  8. bufferedYs = [],
  9. times = [],
  10. }: {
  11. color: string
  12. duration: number
  13. bufferedXs: number[]
  14. bufferedYs: number[]
  15. times: number[]
  16. }): JSX.Element {
  17. return (
  18. <StyledCursor
  19. color={color}
  20. initial={false}
  21. animate={{
  22. x: bufferedXs,
  23. y: bufferedYs,
  24. transition: {
  25. type: 'tween',
  26. ease: 'linear',
  27. duration,
  28. times,
  29. },
  30. }}
  31. width="35px"
  32. height="35px"
  33. viewBox="0 0 35 35"
  34. version="1.1"
  35. pointerEvents="none"
  36. xmlns="http://www.w3.org/2000/svg"
  37. xmlnsXlink="http://www.w3.org/1999/xlink"
  38. >
  39. <path
  40. d="M12,24.4219 L12,8.4069 L23.591,20.0259 L16.81,20.0259 L16.399,20.1499 L12,24.4219 Z"
  41. fill="#ffffff"
  42. />
  43. <path
  44. d="M21.0845,25.0962 L17.4795,26.6312 L12.7975,15.5422 L16.4835,13.9892 L21.0845,25.0962 Z"
  45. fill="#ffffff"
  46. />
  47. <path
  48. d="M19.751,24.4155 L17.907,25.1895 L14.807,17.8155 L16.648,17.0405 L19.751,24.4155 Z"
  49. fill="currentColor"
  50. />
  51. <path
  52. d="M13,10.814 L13,22.002 L15.969,19.136 L16.397,18.997 L21.165,18.997 L13,10.814 Z"
  53. fill="currentColor"
  54. />
  55. </StyledCursor>
  56. )
  57. }
  58. const StyledCursor = styled(motion.g, {
  59. position: 'absolute',
  60. zIndex: 1000,
  61. top: 0,
  62. left: 0,
  63. })