Book Image

Learning JavaScript Robotics

By : Kassandra Perch
Book Image

Learning JavaScript Robotics

By: Kassandra Perch

Overview of this book

Table of Contents (16 chapters)
Learning JavaScript Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Animation events


A lot of movements require waiting for one segment to finish before starting another. Some segments should only be fired at certain times, as well. The best way to handle these timings and communication systems is by using Johnny-Five's animation events.

We tap into these events by assigning callbacks to special attributes on segments. Let's go into the details of each one and see when they will fire.

Events

Details

onstart

The onstart callback fires when the segment has begun playing in the animation.

onstop

The onstop callback is only called when the segment is either in the queue or currently running, but the animation is stopped via animation.stop().

onpause

The onpause callback is only called when the segment is queued or running in an animation that has been paused via animation.pause().

oncomplete

The oncomplete callback only fires when the segment has completed running in an animation. Note: This does NOT apply to looped segments. See the onloop...