Files
shanghai-residences/src/components/animation/flyToAnimation.ts
T

24 lines
596 B
TypeScript

import { flyToAnimationManager } from "./FlyToAnimationManager";
import type { FlyToAnimationOptions } from "./FlyToAnimationManager";
/**
* 飞行动画函数
* 将一个元素从起始位置飞向目标元素
*
* @example
* ```tsx
* const fromRef = useRef<HTMLDivElement>(null);
* const toRef = useRef<HTMLDivElement>(null);
*
* flyToAnimation({
* fromRef,
* toRef,
* targetPosition: "center",
* onComplete: () => console.log("动画完成"),
* });
* ```
*/
export const flyToAnimation = (options: FlyToAnimationOptions) => {
flyToAnimationManager.flyTo(options);
};