Skip to content

Commit 60f3886

Browse files
author
Sergey Danilchenko
committed
fix(runtime-dom): inconsistent behaviour on nested transition groups (#1531)
1 parent 37a14a5 commit 60f3886

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/runtime-dom/src/components/TransitionGroup.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ const TransitionGroupImpl: ComponentOptions = {
132132
child,
133133
resolveTransitionHooks(child, cssTransitionProps, state, instance)
134134
)
135-
positionMap.set(child, (child.el as Element).getBoundingClientRect())
135+
positionMap.set(
136+
child,
137+
getRelativeBoundingClientRect(child.el as Element)
138+
)
136139
}
137140
}
138141

@@ -170,8 +173,21 @@ function callPendingCbs(c: VNode) {
170173
}
171174
}
172175

176+
function getRelativeBoundingClientRect(el: Element) {
177+
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+
)
187+
}
188+
173189
function recordPosition(c: VNode) {
174-
newPositionMap.set(c, (c.el as Element).getBoundingClientRect())
190+
newPositionMap.set(c, getRelativeBoundingClientRect(c.el as Element))
175191
}
176192

177193
function applyTranslation(c: VNode): VNode | undefined {

0 commit comments

Comments
 (0)