Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SVG 動畫二三事
Search
Patrick Wang
January 09, 2015
Programming
0
340
SVG 動畫二三事
Patrick Wang
January 09, 2015
Tweet
Share
More Decks by Patrick Wang
See All by Patrick Wang
使用 Jest 進行 Front-End Unit Test(線上 React 讀書會版)
patw0929
2
560
淺談使用 Appium 進行 React Native 雙平台(iOS & Android)App 的 E2E 自動化測試
patw0929
0
360
使用 Jest 進行 Front-End Unit Test
patw0929
9
2.3k
使用 Sketch 改善程式與設計的合作及標註方式
patw0929
6
1.9k
webpack 簡介
patw0929
2
470
Implement Social Login with Flask & authomatic
patw0929
1
170
淺談 RWD 與實做(用 Susy 1.0.9)
patw0929
2
560
Other Decks in Programming
See All in Programming
[NG India] Event-Based State Management with NgRx SignalStore
markostanimirovic
0
110
remix + cloudflare workers (DO) docker上でいい感じに開発する
yoshidatomoaki
0
130
SwiftUI API Design Lessons
niw
1
260
Going Structural with Named Tuples
bishabosha
0
200
Building Scalable Mobile Projects: Fast Builds, High Reusability and Clear Ownership
cyrilmottier
2
250
Preact、HooksとSignalsの両立 / Preact: Harmonizing Hooks and Signals
ssssota
1
1.3k
スモールスタートで始めるためのLambda×モノリス
akihisaikeda
2
130
DataStoreをテストする
mkeeda
0
280
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
1
220
いまさら聞けない生成AI入門: 「生成AIを高速キャッチアップ」
soh9834
15
4.5k
プロダクト横断分析に役立つ、事前集計しないサマリーテーブル設計
hanon52_
2
360
PHPバージョンアップから始めるOSSコントリビュート / how2oss-contribute
dmnlk
1
970
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Designing for Performance
lara
607
69k
Testing 201, or: Great Expectations
jmmastey
42
7.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
13
1.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Statistics for Hackers
jakevdp
798
220k
Scaling GitHub
holman
459
140k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
4.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Documentation Writing (for coders)
carmenintech
69
4.7k
Transcript
SVG 動畫⼆二三事 patw / Front-End Engineer Gogolook Developers meet up
╳
SVG • Scalable Vector Graphics • Proposed by W3C in
1999. In 2001 the SVG gained its first official release. • XML • Vector vs Bitmap
SVG • Scalable • Smaller sizes (can be gzipped) •
Interactive & Styleable (CSS & JavaScript)
None
None
TOOLS • Inkscape (http://inkscape.org/) • SVG-edit (http://svg-edit.googlecode.com/svn/ branches/stable/editor/svg-editor.html) • Adobe
Illustrator • Sketch
SVG ANIMATIONS
ANIMATED SVG VS. GIFS “By using animated SVGs instead of
GIFs we were able to reduce our page size from 1.6 mb to 389 kb, and reduce our page load time from 8.75 s to 412 ms. That’s a huge difference.” http://oak.is/thinking/animated-svgs/
SVG ANIMATIONS • 更多變化:⽐比起 CSS 3 transition,除了位移、 顏⾊色變化之外,還⽀支援路徑描繪、導引線、形 狀漸變等動畫... •
互動效果:點擊後播放、等待 A 結束若干秒後 播放,或是針對單⼀一元件互動...
SVG ANIMATIONS • 三種實現⽅方法 • CSS • SMIL(Synchronized Multimedia Integration
Language) • JavaScript http://css-tricks.com/video-screencasts/135-three-ways-animate-svg/
SVG ANIMATIONS • CSS 使⽤用時機 • 只要實現簡單的動畫效果 • 只需 CSS
動畫可⽀支援的屬性就可完成的情況 • 了解 CSS 動畫怎麼做
SVG ANIMATIONS • SMIL 使⽤用時機 • 那些 CSS 辦不到的動畫屬性(例如形變) •
要⽤用上 SMIL 的特殊效果,例如在 A 動畫結束 後播放(不需像 CSS 動畫要⾃自⾏行調整延遲時 間),或是點擊後播放之類的
SMIL ANIMATIONS • 不⽤用 CSS、JavaScript 就可實現動畫效果! • 瀏覽器⽀支援度 (http://caniuse.com/#feat=svg- smil)
SMIL ANIMATIONS • <set> • <animate> • <animateColor> • <animateTransform>
• <animateMotion> http://tutorials.jenkov.com/svg/svg-animation.html
SVG ANIMATIONS • JavaScript 使⽤用時機 • 就是要⽤用 JavaScript 的情況,像是動畫可能是 依據接收到的
JSON 來動作的 • 或是需要⼀一些數學邏輯時 • 解決跨瀏覽器的問題 • 需要實現龐⼤大且複雜的動畫 • 太複雜也許就⽤用 Canvas 了
SVG ANIMATIONS • JavaScript Solutions • Snap.svg (http://snapsvg.io/) • GreenSock
(http://codepen.io/GreenSock/pen/ gpDrC) • Velocity.js (http://julian.com/research/velocity/) • SVG Morpheus (http://alexk111.github.io/ SVG-Morpheus/)
DEMO
REFERENCES • http://slides.com/sarasoueidan/animating-svg-with-css- and-smil-full-version • http://css-tricks.com/video-screencasts/135-three- ways-animate-svg/ • http://www.oxxostudio.tw/articles/201409/svg-21-smil- animation.html
• http://tech.mozilla.com.tw/posts/5660/ • http://www.zhangxinxu.com/wordpress/2014/08/so- powerful-svg-smil-animation/