@@ -177,16 +177,11 @@ export class WMLMotionUIProperty<V=any,T="animation" | "transition"> extends WML
177177
178178 setTimeout ( ( ) => {
179179
180- if ( this . motionState === "closed" ) {
181- Object . assign ( this . style , this . keyFrameStyles [ "0%" ] ) ;
182- if ( this . type === "transition" ) {
183- this . currentTransitionInfo . keyframe = "0%"
184- }
185- } else {
186- Object . assign ( this . style , this . keyFrameStyles [ "100%" ] ) ;
187- if ( this . type === "transition" ) {
188- this . currentTransitionInfo . keyframe = "100%"
189- }
180+ let keyframe = this . motionState === "closed" ? "0%" : "100%" ;
181+ Object . assign ( this . style , this . keyFrameStyles [ keyframe ] ) ;
182+
183+ if ( this . type === "transition" ) {
184+ this . currentTransitionInfo . keyframe = keyframe ;
190185 }
191186
192187 if ( this . autoOpen ) {
@@ -285,20 +280,92 @@ export class WMLMotionUIProperty<V=any,T="animation" | "transition"> extends WML
285280 this . currentTransitionInfo . transitionEndStyles . push ( evt ?. propertyName . replace ( / - ./ g, ( match ) => match . charAt ( 1 ) . toUpperCase ( ) ) )
286281 let keyFramePropertyKeys = Object . keys ( this . keyFrameStyles [ this . currentTransitionInfo . keyframe ] )
287282
283+
288284 if ( this . motionState === "closing" ) {
289285 let keyFrameStyleKeys = Object . keys ( this . keyFrameStyles )
290286 let previousKeyFrameIndex = keyFrameStyleKeys . findIndex ( ( key ) => key === this . currentTransitionInfo . keyframe ) + 1
291- keyFramePropertyKeys = Object . keys ( this . keyFrameStyles [ keyFrameStyleKeys [ previousKeyFrameIndex ] ] )
287+ let previousKeyFramePropertyKeys = Object . keys ( this . keyFrameStyles [ keyFrameStyleKeys [ previousKeyFrameIndex ] ] )
288+ keyFramePropertyKeys = keyFramePropertyKeys
289+ . filter ( ( key ) => {
290+ return previousKeyFramePropertyKeys . includes ( key )
291+ } )
292292 }
293- let frameCompleted = keyFramePropertyKeys
293+
294+ keyFramePropertyKeys = keyFramePropertyKeys
294295 . filter ( ( key ) => ! key . includes ( "transition" ) )
296+
297+ if ( keyFramePropertyKeys . includes ( "borderRadius" ) ) {
298+ let index = keyFramePropertyKeys . findIndex ( key => key === "borderRadius" ) ;
299+ keyFramePropertyKeys . splice ( index , 1 , ...[ "borderTopLeftRadius" , "borderTopRightRadius" , "borderBottomLeftRadius" , "borderBottomRightRadius" ] ) ;
300+ }
301+
302+ if ( keyFramePropertyKeys . includes ( "margin" ) ) {
303+ let index = keyFramePropertyKeys . findIndex ( key => key === "margin" ) ;
304+ keyFramePropertyKeys . splice ( index , 1 , ...[ "marginTop" , "marginRight" , "marginBottom" , "marginLeft" ] ) ;
305+ }
306+
307+ if ( keyFramePropertyKeys . includes ( "padding" ) ) {
308+ let index = keyFramePropertyKeys . findIndex ( key => key === "padding" ) ;
309+ keyFramePropertyKeys . splice ( index , 1 , ...[ "paddingTop" , "paddingRight" , "paddingBottom" , "paddingLeft" ] ) ;
310+ }
311+
312+ if ( keyFramePropertyKeys . includes ( "border" ) ) {
313+ let index = keyFramePropertyKeys . findIndex ( key => key === "border" ) ;
314+ keyFramePropertyKeys . splice ( index , 1 , ...[ "borderTop" , "borderRight" , "borderBottom" , "borderLeft" ] ) ;
315+ }
316+
317+ if ( keyFramePropertyKeys . includes ( "borderColor" ) ) {
318+ let index = keyFramePropertyKeys . findIndex ( key => key === "borderColor" ) ;
319+ keyFramePropertyKeys . splice ( index , 1 , ...[ "borderTopColor" , "borderRightColor" , "borderBottomColor" , "borderLeftColor" ] ) ;
320+ }
321+
322+ if ( keyFramePropertyKeys . includes ( "borderWidth" ) ) {
323+ let index = keyFramePropertyKeys . findIndex ( key => key === "borderWidth" ) ;
324+ keyFramePropertyKeys . splice ( index , 1 , ...[ "borderTopWidth" , "borderRightWidth" , "borderBottomWidth" , "borderLeftWidth" ] ) ;
325+ }
326+
327+ if ( keyFramePropertyKeys . includes ( "borderStyle" ) ) {
328+ let index = keyFramePropertyKeys . findIndex ( key => key === "borderStyle" ) ;
329+ keyFramePropertyKeys . splice ( index , 1 , ...[ "borderTopStyle" , "borderRightStyle" , "borderBottomStyle" , "borderLeftStyle" ] ) ;
330+ }
331+
332+ if ( keyFramePropertyKeys . includes ( "background" ) ) {
333+ let index = keyFramePropertyKeys . findIndex ( key => key === "background" ) ;
334+ keyFramePropertyKeys . splice ( index , 1 , ...[ "backgroundImage" , "backgroundPosition" , "backgroundSize" , "backgroundRepeat" , "backgroundAttachment" , "backgroundOrigin" , "backgroundClip" , "backgroundColor" ] ) ;
335+ }
336+
337+ if ( keyFramePropertyKeys . includes ( "font" ) ) {
338+ let index = keyFramePropertyKeys . findIndex ( key => key === "font" ) ;
339+ keyFramePropertyKeys . splice ( index , 1 , ...[ "fontStyle" , "fontVariant" , "fontWeight" , "fontSize" , "lineHeight" , "fontFamily" ] ) ;
340+ }
341+
342+ if ( keyFramePropertyKeys . includes ( "animation" ) ) {
343+ let index = keyFramePropertyKeys . findIndex ( key => key === "animation" ) ;
344+ keyFramePropertyKeys . splice ( index , 1 , ...[ "animationName" , "animationDuration" , "animationTimingFunction" , "animationDelay" , "animationIterationCount" , "animationDirection" , "animationFillMode" , "animationPlayState" ] ) ;
345+ }
346+
347+
348+ if ( keyFramePropertyKeys . includes ( "flex" ) ) {
349+ let index = keyFramePropertyKeys . findIndex ( key => key === "flex" ) ;
350+ keyFramePropertyKeys . splice ( index , 1 , ...[ "flexGrow" , "flexShrink" , "flexBasis" ] ) ;
351+ }
352+
353+ if ( keyFramePropertyKeys . includes ( "grid" ) ) {
354+ let index = keyFramePropertyKeys . findIndex ( key => key === "grid" ) ;
355+ keyFramePropertyKeys . splice ( index , 1 , ...[ "gridTemplateRows" , "gridTemplateColumns" , "gridTemplateAreas" , "gridAutoRows" , "gridAutoColumns" , "gridAutoFlow" ] ) ;
356+ }
357+
358+
359+
360+ let frameCompleted = keyFramePropertyKeys
295361 . every ( ( key ) => {
362+
296363 return this . currentTransitionInfo . transitionEndStyles . includes ( key )
297364 } )
298-
299365 if ( ! frameCompleted ) {
300366 return
301367 }
368+
302369 this . currentTransitionInfo . transitionEndStyles = [ ]
303370 if ( [ "0%" , "100%" ] . includes ( this . currentTransitionInfo . keyframe ) ) {
304371 this . motionState = {
@@ -323,31 +390,40 @@ export class WMLMotionUIProperty<V=any,T="animation" | "transition"> extends WML
323390 this . style . animationPlayState = "paused"
324391 }
325392 else if ( this . type === "transition" ) {
326- let allStyles = getComputedStyle ( this . getElement ( ) )
327- let currentStyles = Object . fromEntries ( Object . entries ( this . style )
328- . map ( ( [ k , v ] ) => {
329- return [ k , allStyles [ k ] ]
330- } ) )
331- this . currentTransitionInfo . currentStyles = {
332- ...currentStyles ,
333- transition :allStyles [ "transition" ]
393+ if ( this . currentTransitionInfo . playState !== "paused" ) {
394+ this . currentTransitionInfo . playState = "paused"
395+ let allStyles = getComputedStyle ( this . getElement ( ) )
396+ let currentStyles = Object . fromEntries ( Object . entries ( this . style )
397+ . map ( ( [ k , v ] ) => {
398+ return [ k , allStyles [ k ] ]
399+ } ) )
400+ this . currentTransitionInfo . currentStyles = {
401+ ...currentStyles ,
402+ transition :allStyles [ "transition" ]
403+ }
404+ Object . assign ( this . style , {
405+ ...currentStyles ,
406+ transition :"none"
407+ } )
334408 }
335- Object . assign ( this . style , {
336- ...currentStyles ,
337- transition :"none"
338- } )
409+
339410
340411 }
341412 }
342413 resumeMotion = ( ) => {
414+
343415 if ( this . type === "animation" ) {
344416 this . style . animationPlayState = "running"
345417 }
346418 else if ( this . type === "transition" ) {
347- Object . assign ( this . style , {
348- ...this . currentTransitionInfo . currentStyles ,
349- ...this . keyFrameStyles [ this . currentTransitionInfo . keyframe ]
350- } )
419+ if ( this . currentTransitionInfo . playState !== "running" ) {
420+ this . currentTransitionInfo . playState = "running"
421+ Object . assign ( this . style , {
422+ ...this . currentTransitionInfo . currentStyles ,
423+ ...this . keyFrameStyles [ this . currentTransitionInfo . keyframe ]
424+ } )
425+ }
426+
351427
352428 }
353429 }
@@ -456,7 +532,8 @@ export class WMLMotionUIProperty<V=any,T="animation" | "transition"> extends WML
456532 currentTransitionInfo :any = {
457533 keyframe :"0%" ,
458534 currentStyles :{ } ,
459- transitionEndStyles :[ ]
535+ transitionEndStyles :[ ] ,
536+ playState :""
460537 }
461538
462539 setupTransitions = ( ) => {
@@ -479,13 +556,13 @@ export class WMLMotionUIProperty<V=any,T="animation" | "transition"> extends WML
479556 return parseFloat ( a ) - parseFloat ( b ) ;
480557 } )
481558 let currentTransitionIndex = sortedStyles . findIndex ( ( [ key ] ) => key == this . currentTransitionInfo . keyframe )
482-
559+
483560 let nextTransitionIndex = {
484561 "opening" : currentTransitionIndex + 1 ,
485562 "closing" : currentTransitionIndex - 1
486563 } [ this . motionState ] ;
487564 this . currentTransitionInfo . keyframe = sortedStyles [ nextTransitionIndex ] [ 0 ]
488- console . log ( ( JSON . stringify ( this . style , null , 2 ) ) )
565+
489566
490567 Object . assign ( this . style , {
491568 ...sortedStyles [ nextTransitionIndex ] [ 1 ]
0 commit comments