drive
drive(output, definition) returns an immutable
PibblAnimationProgram. An accepted
run leases the writable output for its entire lifetime, including surrounding
waits. Competing writers fail unless playback requests replacement explicitly.
Creating this program does not update the signal or start playback. Pass it to
usePlayback, then call play() to run it. The signal is the destination, not
an observed input.
import { drive, tween, usePlayback, useSignal } from "@pibbl/core";
// Call inside a Pibbl component; invoke the returned function from an event handler.function useMovement() { const x = useSignal(0); const movement = drive(x, tween({ from: 0, to: 100, duration: 300 })); const playback = usePlayback(movement); return { x, start: () => playback.play() };}drive replaces the former track name; there is no compatibility alias.
Related types: PibblAnimationDefinition,
PibblAnimationProgram, and
WritableSignal.
API details from source
Section titled “API details from source”
Binds one animation definition to one writable signal.
drive: <T>(output: WritableSignal<T>, definition: PibblAnimationDefinition<T>) => PibblAnimationProgramRelated API: drive, WritableSignal, PibblAnimationDefinition, PibblAnimationProgram.
Parameters
Section titled “Parameters”-
output— Writable signal that receives sampled values. See WritableSignal. -
definition— Animation definition to sample into the signal. See PibblAnimationDefinition .
Returns
Section titled “Returns”A program that animates the supplied output signal. See PibblAnimationProgram.
See also
Section titled “See also”View source — packages/core/src/lib/animation/program.ts:780
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Animation and scheduling companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Tween playback controls: Animate a signal and control the mounted playback with native buttons. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.