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 TickResultA 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 TickResultA 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
#Milliseconds Source
type Milliseconds = NumberTime delta in milliseconds
Re-exports from Hylograph.Transition.Engine
#tick Source
tick :: forall a. Milliseconds -> TransitionState a -> TransitionState aAdvance a transition by a time delta (in milliseconds)
#start Source
start :: forall a. TransitionSpec a -> TransitionState aStart a transition from the beginning
#isComplete Source
isComplete :: forall a. TransitionState a -> BooleanCheck if the transition is complete
#groupValues Source
groupValues :: TransitionGroup -> Array NumberGet current values from all transitions in group
#groupTick Source
groupTick :: Milliseconds -> TransitionGroup -> TransitionGroupTick all transitions in a group
#groupComplete Source
groupComplete :: TransitionGroup -> BooleanCheck if all transitions in group are complete
#group Source
group :: Array (TransitionSpec Number) -> TransitionGroupCreate a group from multiple transition specs
#currentValue Source
currentValue :: forall a. TransitionState a -> aGet the current interpolated value