@@ -27,8 +27,13 @@ import {
2727} from '@vue/runtime-core'
2828import { extend } from '@vue/shared'
2929
30- const positionMap = new WeakMap < VNode , DOMRect > ( )
31- const newPositionMap = new WeakMap < VNode , DOMRect > ( )
30+ interface Position {
31+ left : number
32+ top : number
33+ }
34+
35+ const positionMap = new WeakMap < VNode , Position > ( )
36+ const newPositionMap = new WeakMap < VNode , Position > ( )
3237
3338export type TransitionGroupProps = Omit < TransitionProps , 'mode' > & {
3439 tag ?: string
@@ -132,10 +137,7 @@ const TransitionGroupImpl: ComponentOptions = {
132137 child ,
133138 resolveTransitionHooks ( child , cssTransitionProps , state , instance )
134139 )
135- positionMap . set (
136- child ,
137- getRelativeBoundingClientRect ( child . el as Element )
138- )
140+ positionMap . set ( child , getRelativePosition ( child . el as Element ) )
139141 }
140142 }
141143
@@ -173,21 +175,18 @@ function callPendingCbs(c: VNode) {
173175 }
174176}
175177
176- function getRelativeBoundingClientRect ( el : Element ) {
178+ function getRelativePosition ( el : Element ) : Position {
177179 const elRect = el . getBoundingClientRect ( )
178- if ( ! el . parentElement ) return elRect
179- const parentRect = el . parentElement . getBoundingClientRect ( )
180-
181- return new DOMRectReadOnly (
182- elRect . x - parentRect . x ,
183- elRect . y - parentRect . y ,
184- elRect . width - parentRect . width ,
185- elRect . height - parentRect . height
186- )
180+ const parentRect = el . parentElement ?. getBoundingClientRect ( )
181+
182+ return {
183+ left : elRect . left - ( parentRect ?. left || 0 ) ,
184+ top : elRect . top - ( parentRect ?. top || 0 )
185+ }
187186}
188187
189188function recordPosition ( c : VNode ) {
190- newPositionMap . set ( c , getRelativeBoundingClientRect ( c . el as Element ) )
189+ newPositionMap . set ( c , getRelativePosition ( c . el as Element ) )
191190}
192191
193192function applyTranslation ( c : VNode ) : VNode | undefined {
0 commit comments