Two-way scrubber

ng-gsap

View source

gsapScrub returns a plain WritableSignal bound both ways to the timeline: drag the slider to seek, or hit play and watch the slider follow along. Alongside it, animationSignals mirrors the same timeline read-only — with killOnDestroy: false, since gsapScrub already owns its lifetime.

progress
0.000
isActive
false
duration
0.00s
private container = viewChild.required<ElementRef>('container');
private timeline = gsap.timeline({ paused: true });

private anim = injectGSAP(() => {
  this.timeline
    .to('.box.a', { x: 200, rotate: 180 })
    .to('.box.b', { y: -40 }, '<')
    .to('.box.c', { scale: 1.6 }, '<');
}, { scope: this.container });

// drag the slider to seek the timeline; playing the timeline moves the slider back
protected progress = gsapScrub(this.timeline);

// read-only mirror of the same timeline, for the live readout below
protected playback = animationSignals(this.timeline, { killOnDestroy: false });