@@ -122,27 +122,36 @@ export function connectionUiEffect(block: BlockSvg) {
122122 } ,
123123 workspace . getParentSvg ( ) ,
124124 ) ;
125- // Start the animation.
126- connectionUiStep ( ripple , new Date ( ) , scale ) ;
127- }
128125
129- /**
130- * Expand a ripple around a connection.
131- *
132- * @param ripple Element to animate.
133- * @param start Date of animation's start.
134- * @param scale Scale of workspace.
135- */
136- function connectionUiStep ( ripple : SVGElement , start : Date , scale : number ) {
137- const ms = new Date ( ) . getTime ( ) - start . getTime ( ) ;
138- const percent = ms / 150 ;
139- if ( percent > 1 ) {
140- dom . removeNode ( ripple ) ;
141- } else {
142- ripple . setAttribute ( 'r' , String ( percent * 25 * scale ) ) ;
143- ripple . style . opacity = String ( 1 - percent ) ;
144- disconnectPid = setTimeout ( connectionUiStep , 10 , ripple , start , scale ) ;
145- }
126+ const scaleAnimation = dom . createSvgElement (
127+ Svg . ANIMATE ,
128+ {
129+ 'id' : 'animationCircle' ,
130+ 'begin' : 'indefinite' ,
131+ 'attributeName' : 'r' ,
132+ 'dur' : '150ms' ,
133+ 'from' : 0 ,
134+ 'to' : 25 * scale ,
135+ } ,
136+ ripple ,
137+ ) ;
138+ const opacityAnimation = dom . createSvgElement (
139+ Svg . ANIMATE ,
140+ {
141+ 'id' : 'animationOpacity' ,
142+ 'begin' : 'indefinite' ,
143+ 'attributeName' : 'opacity' ,
144+ 'dur' : '150ms' ,
145+ 'from' : 1 ,
146+ 'to' : 0 ,
147+ } ,
148+ ripple ,
149+ ) ;
150+
151+ scaleAnimation . beginElement ( ) ;
152+ opacityAnimation . beginElement ( ) ;
153+
154+ setTimeout ( ( ) => void dom . removeNode ( ripple ) , 150 ) ;
146155}
147156
148157/**
0 commit comments