Skip to content

[feature] Extend Timeline with sync, call(), and alternate loop support #97

@Karanjot786

Description

@Karanjot786

What to build

Extend the Timeline class in @termuijs/motion with three new capabilities. sync(subTimeline, offsetMs) locks a sub-timeline at a given millisecond offset. call(fn, atMs) fires a callback at an exact millisecond mark. alternate: true in loop options plays the timeline forward then backward in a ping-pong pattern. The timeline auto-requests live mode when playing and drops it on completion.

Acceptance criteria

  • Synced timelines start at the correct offset
  • call(fn, 500) fires at 500ms
  • Alternate loop reverses direction after the first pass
  • Live mode is auto-managed
  • Tests use createVirtualClock from the testing package

Implementation notes

  • Edit packages/motion/src/timeline.ts
  • Edit packages/motion/src/timeline.test.ts
  • Look at packages/motion/src/ for patterns

Example usage

import { Timeline } from '@termuijs/motion';

const tl = new Timeline({ loop: true, alternate: true });

tl.add(box, { x: [0, 100] }, { duration: 500 });
tl.call(() => console.log('halfway'), 250);

const sub = new Timeline();
sub.add(label, { opacity: [0, 1] }, { duration: 200 });
tl.sync(sub, 100); // sub starts at 100ms into tl

tl.play();

GSSoC 2026

This is an intermediate-level issue. Comment "I would like to work on this" to get assigned. You have 7 days to open a PR after assignment.

Read CONTRIBUTING.md before starting.

Metadata

Metadata

Labels

GSSoC 2026Open for GSSoC 2026 contributors.ai-readyStructured issue with full spec for AI coding agentsarea:motion@termuijs/motionenhancementNew feature or requestlevel:intermediate+35 pts. Moderate task.type:feature+10 pts. New feature.

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions