import { _decorator, Component, Node, tween, Tween, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('UITweener')
export class UITweener
{
    private tweenFn: Tween<Node>;

    public fn_TriggerTween(node: Node, delay: number, newPos: Vec3, onUpdate: () => void, onComplete: () => void)
    {
        this.tweenFn = tween(node).to(delay,
                        { position: newPos },
                        {
                            onUpdate: () => { onUpdate(); },
                            onComplete: () => { onComplete(); }
                        }).start();
    }

    public fn_StopTween()
    {
        if (this.tweenFn != null)
            this.tweenFn.stop();
    }
}


