Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for relative animations not working with instant transition parents #2161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
126 changes: 126 additions & 0 deletions dev/projection/animate-relative-mixed-transition-nested.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<html>
<head>
<style>
body {
padding: 0;
margin: 0;
}

#parent {
position: relative;
width: 200px;
height: 200px;
background-color: #00cc88;
display: flex;
justify-content: space-around;
}

#parent.b {
align-items: flex-end;
}

.child-wrapper {
width: 50px;
height: 50px;
background-color: #fff;
}

.child {
width: 50px;
height: 50px;
background-color: #0077ff;
}

[data-layout-correct="false"] {
background: #dd1144 !important;
opacity: 0.5;
}
</style>
</head>
<body>
<div id="parent">
<div class="child-wrapper" id="a-wrapper">
<div class="child" id="a"></div>
</div>
<div class="child-wrapper" id="b-wrapper">
<div class="child" id="b"></div>
</div>
</div>

<script src="../../packages/framer-motion/dist/projection.dev.js"></script>
<script src="./script-assert.js"></script>
<script src="./script-animate.js"></script>
<script>
const { createNode, relativeEase } = window.Animate
const { matchViewportBox } = window.Assert

const parent = document.getElementById("parent")
const aWrapper = document.getElementById("a-wrapper")
const a = document.getElementById("a")
const bWrapper = document.getElementById("b-wrapper")
const b = document.getElementById("b")

const transition = { duration: 1 }

const parentProjection = createNode(
parent,
undefined,
{},
transition
)

const aWrapperProjection = createNode(
aWrapper,
parentProjection,
{},
{ type: false }
)
const bWrapperProjection = createNode(
bWrapper,
parentProjection,
{},
{ duration: 0 }
)

const aProjection = createNode(
a,
aWrapperProjection,
{},
transition
)
const bProjection = createNode(
b,
bWrapperProjection,
{},
transition
)

parentProjection.willUpdate()
aWrapperProjection.willUpdate()
bWrapperProjection.willUpdate()
aProjection.willUpdate()
bProjection.willUpdate()

parent.classList.add("b")

parentProjection.root.didUpdate()

frame.postRender(() => {
frame.postRender(() => {
matchViewportBox(a, {
bottom: 200,
left: 25,
right: 75,
top: 150,
})
matchViewportBox(b, {
bottom: 200,
left: 125,
right: 175,
top: 150,
})
})
})
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ export function createProjectionNode<I>({
projectionFrameData.resolvedTargetDeltas =
projectionFrameData.recalculatedProjection =
0

console.log("-------------", this.nodes)
this.nodes!.forEach(propagateDirtyNodes)
this.nodes!.forEach(resolveTargetDelta)
this.nodes!.forEach(calcProjection)
Expand Down Expand Up @@ -1024,6 +1024,8 @@ export function createProjectionNode<I>({
this.attemptToResolveRelativeTarget
)

console.log(this.instance.id, canSkip)

if (canSkip) return

const { layout, layoutId } = this.options
Expand Down