狠狠撸

狠狠撸Share a Scribd company logo
以 Vue / GSAP / D3 為核?心的
網?頁視覺動態整合與架構設計
墨?雨設計 吳哲宇

MOPCON @ 2017.10.29
http://monoame.com/
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
吳哲宇

動畫互動網?頁程式入?門講師

墨?雨設計 Monoame Design 

設計/網?頁全端雙棲的?工程師

為了了有趣的想法赴湯蹈火
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
Outline
? Web development - Vue framework

? Animation basic & Math

? Vuex structure for controlling page motion

? Abstract concept - component for animation

? Lifecycle and framework
Web development -
Vue framework
Jquery Style
DOM
$(“label”).text(“new Text”)
@click
@click
Vue Style
DOM
vm.labelText = “newText”
@click
@click
labelText = “new Text”
Data
Why additional Layer?
Manage Complex
Will increase after each layer
Data Layer
Map Layer
View Layer
Functional
Programming
Data Layer : Static
Map Layer : Transform
View Layer : Only Show
Animation basic & Math
Where animation begin
T=0
Where animation begin
T=1
Where animation begin
T=2
Where animation begin
T=2T=1T=0
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
Continuous Change
T=2
PosX = 80
T=1
PosX = 40
T=0
PosX = 0
T=5
PosX = 200
T=4
PosX = 160
T=3
PosX = 120
How does
this look like?
Linear
y= 4x
ㄧ樣從起點到終點
有不同的走法
y=240-(60-x)^2 / 15
y= (x)^2 / 15
y= 4x
EaseIn
y=240-(60-x)^2 / 15
EaseOut
y= (x)^2 / 15
EaseIn
y=240-(60-x)^2 / 15
EaseOut
y= (x)^2 / 15
Concept:
Map Time into Function
Concept:
Map Time into Function
Ease
Function
Time (T=0,1,2,…) Pos=20,40,60….
Concept:
Map Time into Function
Time (T=0,1,2,…)
Pos=20,40,60….
Time
y= sin(x) y= exp(x) y= mod(x,10)
Many kinds of shape functions
Example: Sin
y= sin(x)
Scroll Pos
TranslateX
Example: mod+ceil -> stair
y=
mod(ceil(x/3),3))
Scroll Pos
TranslateX
https://goo.gl/PrgdME
Sin
+ Stair
http://easings.net/zh-tw Easing 函數速查表
Circle
R=1
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
https://goo.gl/rbh5vG
Vuex structure for
controlling page motion
Traditional Scroll Effect
Scroll
Event
DOM
translateX( scrollTop*50 px) scrollTop
Too Messy to update together
Traditional Scroll Effect
Scroll
EventDOM
A
B
C
Vue Style Scroll Effect
Scroll
EventDOM
A
B
C
Data:
scrollTop
=50…
Map
Map
Map
Traditional Scroll Effect
Scroll
Event
DOM
translateX( scrollTop*50 px)
Data:
scrollTop
Vue Watch Data
:style Math
Map
Scroll
EventDOM
A
B
C
Data:
scrollTop
=50…
Map
Map
Map
Trigger By Data change
instead of Event
Abstract concept -
component for animation
Problem
too much state / behavior
Example:
狠狠撸 In on Scroll
Slot for inner Element
Central
State
Input
Component
Component
Component
Update element Top
Use Slot to insert inner Element
Use CSS Class to Control
Animation Graph
http://2017.n3xtcon.com/
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
Lifecycle and
framework
Vue -> Auto Generate
DOM Object
丑迟迟辫://蝉补惫颈苍驳.别苍别谤驳测辫补谤办.辞谤驳.迟飞/家庭电器?用电家计簿
丑迟迟辫://蝉补惫颈苍驳.别苍别谤驳测辫补谤办.辞谤驳.迟飞/家庭电器?用电家计簿
丑迟迟辫://蝉补惫颈苍驳.别苍别谤驳测辫补谤办.辞谤驳.迟飞/家庭电器?用电家计簿
Lifecycle- mount Object
D3 / GSAP
Bind Object
On mount
Svg as root (this.$el)
D3 select initialize
Svg
Bubble
Component
Prop Data Change
Watch
D3 Update
Graph
以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇
丑迟迟辫://蝉补惫颈苍驳.别苍别谤驳测辫补谤办.辞谤驳.迟飞/家庭电器?用电家计簿
Summary
? Data to Change State

? Math to Transform (MAP) / Easing

? Centralize UI Inputs (scrollTop…)

? Combine Frameworks
Q & A

More Related Content

以 Vue / GSAP / D3 為核心的網頁視覺動態整合與架構設計 - 吳哲宇