Praise for SVG Animations
Few people are as passionate about animation on the web as Sarah, and her new book is a treasure trove of knowledge. If you want to animate SVG on the web, you simply must read this book.
Jack Doyle, GreenSock
I find Sarah Drasners animations a delight to seeexpressive, fluid, and graceful. But not only is she a superb animator, she can also explain exactly why and how to use the tools at your disposal to create the animations you desire. Her cogent and lucid prose guides you through the concepts you will need to understand, and she recommends the best libraries to use for robust, cross-browser development. Even if you think you know SVG and animation inside-out, you will not regret owning this essential book.
Chris Lilley, inventor of SVG
SVG Animations is a must-read for anyone working with SVG. Sarah Drasner has put all the most useful things she knows about animating SVG in one place, showing you how to make good design decisions around animation and how to pull it off with expert technical skill.
Val Head, author of Designing Interface Animation
Sarah Drasner is both an incredibly artistic animator and a pragmatic, detail-oriented web developer. SVG Animations provides practical solutions for animating vector graphics on the web, using the tools available today, without letting technical limitations cramp your creativity.
Amelia Bellamy-Royds, coauthor of SVG Colors, Patterns & Gradients, SVG Essentials (second edition), SVG Text Layout, and Using SVG with CSS3 and HTML5 (OReilly)
SVG Animations
by Sarah Drasner
Copyright 2017 Sarah Drasner. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Meg Foley
- Production Editor: Shiny Kalapurakkel
- Copyeditor: Molly Ives Brower
- Proofreader: Rachel Head
- Indexer: Wendy Catalano
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- April 2017: First Edition
Revision History for the First Edition
- 2017-03-16: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491939703 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. SVG Animations, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-93970-3
[LSI]
Dedication
This book is dedicated to Dizzy, my spappem.
Foreword
Have you ever learned a new word, then had the opportunity to use that word in the perfect situation come up a number of times that week? Thats what it feels like when you start learning SVG. To layer on the metaphors, its like discovering your toolbox has been missing a tool all this time.
As a designer and developer, now that Ive dug into SVG, I can tell you I work with it almost every single day. Not necessarily because Im jamming SVG into projects because I can, but because its so often the right tool for the job. After you read this book and SVG becomes your tool too, I think you too will find yourself reaching for it regularly. It will pop to mind when youre working, just like that satisfying moment when a new word youve learned comes in useful.
Perhaps youll think of SVG when you need to replace a logo with one that will display crisply on screens of any pixel density. Perhaps youll think of SVG when you need an icon system, a chart or graph, or a vector background pattern. Now that youre holding this book in your hands, youll almost certainly think of SVG when you think of animation.
SVG is uniquely qualified for animation. Its the single most powerful tool there is for animation on the web. Partly thats because SVG is made of numbers. SVG essentially draws with geometry. And on the web, numbers are easy and intuitive to manipulate and animate. Perhaps you know that you can fade out an elementa rudimentary animationby animating opacity from 1 to 0. So too you could animate the radius of a circle, the coordinates of a rectangle, or a point along a path.
Another reason SVG animation is so compelling is how many ways there are to do it. There are a variety of native technologies to choose from, and libraries built on top of those to help. How do you know what to choose? It requires some knowledge and consideration. Fortunately, youve made the perfect purchase.
Sarah is the ultimate tour guide for all of this. Shes not just an experienced technical writer, but an accomplished vector artist and frontend developer as well. She has been bringing her own SVG art to life through animation for years and years. She knows the tools. She knows the landscape. She knows how to get to the meat of what is important about all this and explain it.
Im not gasconading for Sarah without reason. Ive worked with Sarah and ingurgitated her knowledge on SVG animation much to my benediction. If youre thinking Im a frontend developer already, and have gotten by just fine without this, remember that you dont reach for what you dont know. Read on, and become an SVG opsimath.
Chris Coyier
Preface
SVG Animation: Where Art and Code Intersect
People joke that working with Scalable Vector Graphics, one must be an archaeologist, and as funny as it is, theres a lot of truth there. SVG has long lain dormant, put aside for its previous lack of support and understanding. But a few twists in the web plot have allowed for its resurgence, now-excellent support, and now-strong standing in the community:
Data visualization
Being able to visually express concepts with the actual data is vital for communication of complex concepts.
Responsive
In a world of thousands of devices, viewports, and pixel densities, the ability to use one graphic and have it be crisp and scale to all of them is a game-changer.
Performance
When SVG is built properly, with reduced path points and simple shapes, it can offer tiny file sizes that bitmaps cant compete with. With properly constructed SVGs we can make our web lightning-fast and available to all.
A navigable DOM
This point is a sleeper hit: you might not immediately notice it as a boon to development, but SVGs integration into the DOM means you have the ability to offer more information to screen readers and make your graphics truly accessible. You can also reach right inside and animate or manipulate small sections at a time. In this book, youll discover how powerful a feature this is indeed. No crazy z-indexing and absolute positioning required!
SVG can move smoothly, freely. Weve only just hit the surface of its potential. As a developer, you can feel the rush of dopamine as you watch this flexible medium bounce and snap. You can create realistic movements or stylized motions that complement your branding. The amazing thing about SVG is that you get to draw with math.