Onboarding Animation with KeyshapeJS
Onboarding means giving an introduction about products or services to new users. It is often presented as a series of steps, which the users go through. Animations can make onboarding more playful and fun.
Below is an imaginary onboarding example made in Keyshape. It is made of four steps. Animations are used between the steps to make it more engaging. Press the “Next” button to see how it works!
Creating the Animation in Keyshape
You can find the Keyshape file for the animation at the bottom of this page so you can open in it Keyshape and see how it has been made. The animation has only one timeline. It has been split into four steps and the animation progresses from one step to the next one when the "Next" button is pressed. The steps are:
- The first step at 0s
- The second step at 1s
- The third step at 2s
- The last step at 4.5s
The animation was then exported as an SVG with KeyshapeJS animation.
The Next Button
The “Next” button changes the animation play range to play from the current step to the next step.
Steps are defined in an array so that adjusting them is easy. Each number in the array represents a time value for a step. The times are given in milliseconds.
Below is the code which changes the play range. It compares the current animation time to the times in the array. When it finds a time, which comes after the current time, it changes the play range to it.
Playing and pausing animations can happen at a global or timeline level. The top level object controls how a global timeline progresses. The “global=paused” parameter in the object URL sets the global timeline to paused after the animation has been loaded. The timeline level pauses and plays only one timeline. If the global timeline is paused, then nothing happens even if a timeline is set to play.
The code below calls globalPlay() for the top level ks object to make it play the first time after the animation has been loaded.
There is also a call to play() for the timeline. The timeline will then play until it reaches the play range end time.
The Go to Start Button
In addition to the “Next” button, there is the “Go to Start” button. Onboarding doesn’t necessarily need it, but it was added so that it is possible to try the example multiple times.
The button just pauses the timeline and sets its time to zero.
It would be easy to add more steps by adding them to the animation in Keyshape and by including them in the stepTimes array.
There are also other ways to improve the example. For example, the label of the “Next” button could be changed to “Finished” when the animation reaches the end.
- Document created.