This repo stores files for a animation which you can watch on this Codepen page.
All the project related files are stored inside src/
directory.
This directory holds SVG images which are included inside index.html
file. During include all IDs inside images are converted to classes for better reusability and to remove risk of potential ID names collision. It's optional and I use idsToClasses
filter to take care of that. It's all possible thanks to gulp-file-include.
Here the scripts are divided into:
When all audio files are loaded body
gets is-ready class and timeline controls are activated.
The directory where all timelines are stored. All scenes are imported into main-timeline.js
. It looks kind of like a main CSS file where you import small components.
const.js
– this is where I put constant values.objects.js
– all object which are going to be animated can be accessed through this module.sounds.js
– sound files to be loaded are specified in this place (all of them are pulled from the media directory).
sounds.js
– a little script that utilises howler.js to:- preload and play
ogg
andmp3
files, – sync the sound with the timeline.
- preload and play
timeline-ui
– it adds timeline controls (play/start button + range input). It also takes care of pausing/resuming sound when the animation isn't visible (so it's synced with requestAnimationFrame which automatically pauses when off screen).
The directory where audio files are stored. Could also be used for images or videos.
Styles for scene container and timeline UI.
All SVG files are imported here. This is the file which holds all the SVG objects. They're imported inside <g>
(groups) and embedded inside main <svg>
object. Animated GSAP text is kept on a separate layer called scene__outro-text
(outside of SVG context).
You can ran local server, play around with the repo, and preview your changes. 👍
- Clone the repo.
- Install NodeJS (tested on v5).
- Run
npm install
. - Run
npm start
. - The Codepen demo page should open up in you defaut browser with animation loaded from your local repo served from http://localhost:3000.
- Please make sure that you don't have any other servers running on
localhost:3000
– that would not allow to start the local server with the animation. - You may want to open dev tools in your browser and activate disable cache to see your recent updates.
- Livereloading isn't supported at the moment. That means you'll have to refresh Codepen's page to see your local adjustments.
Because of 2 paid plugins I've used: MorphSVGPlugin and SplitText. I can't include them in this open-for-everyone repo but they are available for public use on Codepen!
Short answer: probably the best animation library for JS. ;) Want more information? Go to the library's homepage.