Module

Hylograph.Transition.Consumers

Package
purescript-hylograph-transitions
Repository
afcondon/purescript-hylograph-transitions

Tick consumers for transitions: adapters that make a transition, or a group of them, something the Coordinator can tick.

These need nothing beyond this package (the Engine and the Coordinator), which is why they live here. Until 0.1.1 they were in hylograph-simulation, so that a page with no simulation in it had to take the simulation package to animate anything. The consumer for a force simulation is Hylograph.Simulation.Consumers in that package.

#transitionConsumer Source

transitionConsumer :: forall a. Ref (TransitionState a) -> (a -> Effect Unit) -> Milliseconds -> Effect TickResult

A tick function for one transition.

Takes a Ref to the transition's state and an effect to run on each tick with the current value. Completed when the transition finishes.

stateRef <- Ref.new (Engine.start mySpec)
let consumer = transitionConsumer stateRef \value -> setOpacity element value
C.register coord { tick: consumer, onComplete: log "done" }

#transitionGroupConsumer Source

transitionGroupConsumer :: Ref TransitionGroup -> (Array Number -> Effect Unit) -> Milliseconds -> Effect TickResult

A tick function for a group of transitions run together.

Takes a Ref to the group and an effect to run on each tick with all the current values. Completed when every transition has finished.

groupRef <- Ref.new (Engine.group [spec1, spec2, spec3])
let consumer = transitionGroupConsumer groupRef \values -> draw values
C.register coord { tick: consumer, onComplete: log "all done" }

Re-exports from Hylograph.Transition.Coordinator

#TickResult Source

data TickResult

Result of a tick - tells coordinator what to do next

Constructors

#Milliseconds Source

type Milliseconds = Number

Time delta in milliseconds

Re-exports from Hylograph.Transition.Engine

#tick Source

tick :: forall a. Milliseconds -> TransitionState a -> TransitionState a

Advance a transition by a time delta (in milliseconds)

#start Source

start :: forall a. TransitionSpec a -> TransitionState a

Start a transition from the beginning

#isComplete Source

isComplete :: forall a. TransitionState a -> Boolean

Check if the transition is complete

#groupValues Source

groupValues :: TransitionGroup -> Array Number

Get current values from all transitions in group

#groupTick Source

groupTick :: Milliseconds -> TransitionGroup -> TransitionGroup

Tick all transitions in a group

#groupComplete Source

groupComplete :: TransitionGroup -> Boolean

Check if all transitions in group are complete

#group Source

group :: Array (TransitionSpec Number) -> TransitionGroup

Create a group from multiple transition specs

#currentValue Source

currentValue :: forall a. TransitionState a -> a

Get the current interpolated value