Basic tween

ng-gsap

View source

injectGSAP runs its callback inside an Angular render effect. Nothing here declares what the animation depends on: Angular tracks the signals you read, and open() is read inside the callback. Click the box — nothing else is wired up.

private container = viewChild.required<ElementRef>('container');
protected open = signal(false);

injectGSAP(() => {
  // `open` is read here, so this re-runs whenever it changes
  gsap.to('.box', {
    x: this.open() ? 220 : 0,
    rotate: this.open() ? 90 : 0,
  });
}, { scope: this.container });

// a plain signal write — no contextSafe needed, the callback re-runs itself
protected toggle(): void {
  this.open.update((v) => !v);
}