@@ -466,6 +466,34 @@ const setSelectRect = (
466466 )
467467}
468468
469+ const getElementDurationTime = ( elementId ?: string ) => {
470+ const element = elementId ? querySelectById ( elementId ) : getDocument ( ) . body
471+ const transitionDuration = window . getComputedStyle ( element ) . getPropertyValue ( 'transition-duration' )
472+ const transitionDelay = window . getComputedStyle ( element ) . getPropertyValue ( 'transition-delay' )
473+ let delayTime = 0
474+ const getMaxMillisecondNumber = ( arr : string [ ] ) => {
475+ const millisecondNumber = arr . map ( ( item ) => {
476+ if ( item . endsWith ( 'ms' ) ) {
477+ return parseFloat ( item )
478+ } else {
479+ return parseFloat ( item ) * 1000
480+ }
481+ } )
482+ return millisecondNumber . length ? Math . max ( ...millisecondNumber ) : 0
483+ }
484+ if ( transitionDuration ) {
485+ const transitionDurations = transitionDuration . split ( ',' )
486+ delayTime += getMaxMillisecondNumber ( transitionDurations )
487+ }
488+
489+ if ( transitionDelay ) {
490+ const transitionDelays = transitionDelay . split ( ',' )
491+ delayTime += getMaxMillisecondNumber ( transitionDelays )
492+ }
493+
494+ return delayTime
495+ }
496+
469497export const updateRect = ( id ?: string ) => {
470498 id = ( typeof id === 'string' && id ) || getCurrent ( ) . schema ?. id
471499 clearHover ( )
@@ -481,7 +509,9 @@ export const updateRect = (id?: string) => {
481509 const isBodySelected = ! selectState . componentName && selectState . width > 0
482510
483511 if ( id || isBodySelected ) {
484- setTimeout ( ( ) => setSelectRect ( id ) )
512+ // 获取元素动画持续时间
513+ const waitTime = getElementDurationTime ( id )
514+ setTimeout ( ( ) => setSelectRect ( id ) , waitTime )
485515 } else {
486516 clearSelect ( )
487517 }
@@ -816,7 +846,6 @@ export const dragMove = (event: DragEvent, isHover: boolean) => {
816846// type == clickTree, 为点击大纲; type == loop-id=xxx ,为点击循环数据
817847export const selectNode = async ( id : string , type ?: string , isMultiple = false ) => {
818848 const { node } = useCanvas ( ) . getNodeWithParentById ( id ) || { }
819-
820849 let element = querySelectById ( id )
821850
822851 if ( element && node ) {
@@ -825,7 +854,6 @@ export const selectNode = async (id: string, type?: string, isMultiple = false)
825854 }
826855
827856 const nodeIsSelected = setSelectRect ( id , element , { isMultiple, type, schema : node } )
828-
829857 // 执行setSelectRect之后再去判断multiSelectedStates的长度
830858 if ( multiSelectedStates . value . length === 1 ) {
831859 const { schema : node , parent, type } = multiSelectedStates . value [ 0 ]
@@ -851,6 +879,7 @@ export const selectNode = async (id: string, type?: string, isMultiple = false)
851879 if ( multiSelectedStates . value . length === 1 ) {
852880 const { schema : node , parent, type, id } = multiSelectedStates . value [ 0 ]
853881 canvasState . emit ( 'selected' , node , parent , type , id )
882+
854883 return node
855884 } else {
856885 canvasState . emit ( 'selected' )
0 commit comments