屏幕录制2020-11-25 下午2.06.49.mov (155.78KB)

文件

交互.framerx.zip

代码

  1. import { Override, Data, useTransform, motionValue } from "framer";
  2. const appState = Data({
  3. tapState: false,
  4. tapStartState: false,
  5. position: 0,
  6. });
  7. const transition = {
  8. duration: 0.25,
  9. ease: "easeInOut",
  10. };
  11. const transition1 = {
  12. duration: 0.2,
  13. ease: "easeInOut",
  14. };
  15. const positionX = motionValue(0);
  16. export function TapFrame(): Override {
  17. return {
  18. onTap: () => {
  19. appState.tapState = !appState.tapState;
  20. },
  21. animate: {
  22. backgroundColor: appState.tapState ? "#EA3348" : "#E5E5E5",
  23. },
  24. transition: transition1,
  25. };
  26. }
  27. export function Circle(): Override {
  28. const width = useTransform(positionX, [0, 7, 14], [14, 18, 14]);
  29. return {
  30. animate: {
  31. x: appState.tapState ? 14 : 0,
  32. },
  33. x: positionX,
  34. backgroundColor: appState.tapState ? "#fff" : "transparent",
  35. transition: transition,
  36. width: width,
  37. };
  38. }