官网:https://www.framer.com/docs/introduction/

cnpm i framer-motion

基本用法

  1. 框架:next.js
  2. //css
  3. .title{
  4. font-size: 30px;
  5. }
  6. .ball{
  7. height: 10px;
  8. width: 10px;
  9. background-color: chocolate;
  10. }
  11. //page/about
  12. import React from 'react'
  13. import { motion } from 'framer-motion'
  14. function index() {
  15. return (
  16. <div>
  17. <div className="title">demo</div>
  18. <motion.div
  19. className="ball"
  20. animate={{
  21. x: 150,
  22. y:150,
  23. rotate:300
  24. }}
  25. />
  26. </div>
  27. )
  28. }
  29. export default index

chrome_RrS3mkFeg5.gif

1.annimation

 <motion.div
          className="ball"
          animate={{
            x: [0,100,0],
            y:150,
            rotate:300
          }}
        />

chrome_dgdi9ybF66.gif

     <svg height="600" width="600">
          <motion.circle  
          cx={500}
          animate={{ cx: [null, 100, 200],cy:50,r:40,fill:'#ccc',stroke:"#000",strokeWidth:"5" }} 
          transition={{duration: 3, times: [0, 0.2, 1] }}
          />
          </svg>

chrome_rPbYtGwzL5.gif