From d8863c3188cf0c4647b70d3dc9ec5f2fffe5525c Mon Sep 17 00:00:00 2001 From: Sophie Zhang Date: Thu, 4 Apr 2024 11:21:28 -0400 Subject: zoom fade rotate --- src/client/views/nodes/trails/SlideEffect.tsx | 81 ++++++++++++++++++--------- 1 file changed, 56 insertions(+), 25 deletions(-) (limited to 'src/client/views/nodes/trails/SlideEffect.tsx') diff --git a/src/client/views/nodes/trails/SlideEffect.tsx b/src/client/views/nodes/trails/SlideEffect.tsx index ae25bfb90..af0e7461b 100644 --- a/src/client/views/nodes/trails/SlideEffect.tsx +++ b/src/client/views/nodes/trails/SlideEffect.tsx @@ -1,5 +1,5 @@ import { Button } from '@mui/material'; -import { useSpring, animated, easings } from '@react-spring/web'; +import { useSpring, animated, easings, to } from '@react-spring/web'; import React, { useEffect, useState } from 'react'; import { PresEffectDirection } from './PresEnums'; @@ -7,6 +7,7 @@ export enum EffectType { ZOOM = 'zoom', FADE = 'fade', BOUNCE = 'bounce', + ROTATE = 'rotate', } interface Props { @@ -47,16 +48,52 @@ export default function SpringAnimation({ dir, friction, tension, mass, effectTy const zoomConfig = { from: { + scale: 0, x: 0, y: 0, - opacity: 0, - scale: 0, + opacity: 1, + // opacity: 0, }, to: { + scale: 1, x: 0, y: 0, opacity: 1, + // opacity: 1, + config: { + tension: tension, + friction: friction, + mass: mass, + }, + }, + }; + + const fadeConfig = { + from: { + opacity: 0, scale: 1, + x: 0, + y: 0, + }, + to: { + opacity: 1, + scale: 1, + x: 0, + y: 0, + config: { + tension: tension, + friction: friction, + mass: mass, + }, + }, + }; + + const rotateConfig = { + from: { + x: 0, + }, + to: { + x: 360, config: { tension: tension, friction: friction, @@ -131,6 +168,10 @@ export default function SpringAnimation({ dir, friction, tension, mass, effectTy api.start(bounceConfig); } else if (effectType === EffectType.ZOOM) { api.start(zoomConfig); + } else if (effectType === EffectType.ROTATE) { + api.start(rotateConfig); + } else if (effectType === EffectType.FADE) { + api.start(fadeConfig); } }; @@ -147,28 +188,18 @@ export default function SpringAnimation({ dir, friction, tension, mass, effectTy // handleClick(); // }} > - {/* style={{ - width: "50px", - height: "50px", - backgroundColor: "#ff6d6d", - borderRadius: "4px", - ...springs, - }} */} - - {children} - - {/* */} + {effectType !== EffectType.ROTATE ? ( + + {children} + + ) : ( + `rotate(${val}deg)`) }}>{children} + )} ); } -- cgit v1.2.3-70-g09d2