@@ -103,23 +103,35 @@ const heroAnimation = async () => {
103103 // Convert SVG path pulled from AE masks
104104 let pathInstance = new Path2D ( path )
105105
106- ctx . setLineDash ( [ pathLength ] )
107- ctx . lineDashOffset = pathLength
106+ if ( ! isReduceMotionEnabled ) {
107+ ctx . setLineDash ( [ pathLength ] )
108+ ctx . lineDashOffset = pathLength
108109
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 )
112116 }
117+
113118 return { ctx, pathInstance }
114119 }
115120
116- const initLogo = ( { canvas, image, positionStart : [ posX , posY ] } ) => {
121+ const initLogo = ( { canvas, image, positionStart : [ posX , posY ] , positionEnd : [ endX , endY ] } ) => {
117122 const ctx = canvas . getContext ( '2d' )
118- ctx . globalAlpha = 0
119123 // Same reason for conversion as initSwoops
120124 ctx . translate ( posX - image . naturalWidth / 2 , posY - image . naturalHeight / 2 )
121125
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+ }
123135
124136 return ctx
125137 }
@@ -148,29 +160,6 @@ const heroAnimation = async () => {
148160 }
149161
150162 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 ) ;
174163 return ;
175164 }
176165
0 commit comments