@@ -103,23 +103,35 @@ const heroAnimation = async () => {
103
103
// Convert SVG path pulled from AE masks
104
104
let pathInstance = new Path2D ( path )
105
105
106
- ctx . setLineDash ( [ pathLength ] )
107
- ctx . lineDashOffset = pathLength
106
+ if ( ! isReduceMotionEnabled ) {
107
+ ctx . setLineDash ( [ pathLength ] )
108
+ ctx . lineDashOffset = pathLength
108
109
109
- if ( hasDebugParam ) {
110
- ctx . strokeStyle = debugColor
111
- ctx . stroke ( pathInstance )
110
+ if ( hasDebugParam ) {
111
+ ctx . strokeStyle = debugColor
112
+ ctx . stroke ( pathInstance )
113
+ }
114
+ } else {
115
+ ctx . drawImage ( image , 0 , 0 )
112
116
}
117
+
113
118
return { ctx, pathInstance }
114
119
}
115
120
116
- const initLogo = ( { canvas, image, positionStart : [ posX , posY ] } ) => {
121
+ const initLogo = ( { canvas, image, positionStart : [ posX , posY ] , positionEnd : [ endX , endY ] } ) => {
117
122
const ctx = canvas . getContext ( '2d' )
118
- ctx . globalAlpha = 0
119
123
// Same reason for conversion as initSwoops
120
124
ctx . translate ( posX - image . naturalWidth / 2 , posY - image . naturalHeight / 2 )
121
125
122
- ctx . drawImage ( image , 0 , 0 )
126
+ if ( ! isReduceMotionEnabled ) {
127
+ ctx . globalAlpha = 0
128
+ ctx . drawImage ( image , 0 , 0 )
129
+ } else {
130
+ ctx . globalAlpha = 1
131
+ const deltaX = endX - posX ;
132
+ const deltaY = endY - posY ;
133
+ ctx . drawImage ( image , deltaX , deltaY ) ;
134
+ }
123
135
124
136
return ctx
125
137
}
@@ -148,29 +160,6 @@ const heroAnimation = async () => {
148
160
}
149
161
150
162
if ( isReduceMotionEnabled ) {
151
- // Render final state immediately
152
- heroSwoops . forEach ( ( swoop ) => {
153
- const { ctx, pathInstance, image, canvas } = swoop ;
154
- ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
155
- ctx . lineDashOffset = 0 ;
156
- ctx . stroke ( pathInstance ) ;
157
- ctx . globalCompositeOperation = 'source-in' ;
158
- ctx . drawImage ( image , 0 , 0 ) ;
159
- ctx . globalCompositeOperation = 'source-over' ;
160
- } ) ;
161
-
162
- const {
163
- ctx,
164
- image,
165
- canvas,
166
- positionStart : [ startX , startY ] ,
167
- positionEnd : [ endX , endY ] ,
168
- } = logo ;
169
- ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
170
- ctx . globalAlpha = 1 ;
171
- const deltaX = endX - startX ;
172
- const deltaY = endY - startY ;
173
- ctx . drawImage ( image , deltaX , deltaY ) ;
174
163
return ;
175
164
}
176
165
0 commit comments