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

Remove mount layout animation check #2853

Open
wants to merge 5 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ interface MeasureContextProps {
type MeasureProps = MotionProps &
MeasureContextProps & { visualElement: VisualElement }

/**
* Track whether we've taken any snapshots yet. If not,
* we can safely skip notification of didUpdate.
*/
let hasTakenAnySnapshot = false

class MeasureLayoutWithContext extends Component<MeasureProps> {
/**
* This only mounts projection nodes for components that
Expand All @@ -46,7 +52,10 @@ class MeasureLayoutWithContext extends Component<MeasureProps> {
switchLayoutGroup.register(projection)
}

projection.root!.didUpdate()
if (hasTakenAnySnapshot) {
projection.root!.didUpdate()
}

projection.addEventListener("animationComplete", () => {
this.safeToRemove()
})
Expand Down Expand Up @@ -74,6 +83,8 @@ class MeasureLayoutWithContext extends Component<MeasureProps> {
*/
projection.isPresent = isPresent

hasTakenAnySnapshot = true

if (
drag ||
prevProps.layoutDependency !== layoutDependency ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,10 @@ export function createProjectionNode<I>({

// Note: currently only running on root node
startUpdate() {
console.log("update blocked")
if (this.isUpdateBlocked()) return

console.log("start update")
this.isUpdating = true

this.nodes && this.nodes.forEach(resetSkewAndRotation)
Expand All @@ -628,6 +630,7 @@ export function createProjectionNode<I>({

willUpdate(shouldNotifyListeners = true) {
this.root.hasTreeAnimated = true

if (this.root.isUpdateBlocked()) {
this.options.onExitComplete && this.options.onExitComplete()
return
Expand Down Expand Up @@ -699,26 +702,27 @@ export function createProjectionNode<I>({

if (!this.isUpdating) {
this.nodes!.forEach(clearIsLayoutDirty)
}
} else {
this.isUpdating = false

this.isUpdating = false
/**
* Write
*/
this.nodes!.forEach(resetTransformStyle)

/**
* Write
*/
this.nodes!.forEach(resetTransformStyle)
/**
* Read ==================
*/
// Update layout measurements of updated children
this.nodes!.forEach(updateLayout)

/**
* Read ==================
*/
// Update layout measurements of updated children
this.nodes!.forEach(updateLayout)
/**
* Write
*/
// Notify listeners that the layout is updated
this.nodes!.forEach(notifyLayoutUpdate)
}

/**
* Write
*/
// Notify listeners that the layout is updated
this.nodes!.forEach(notifyLayoutUpdate)
this.clearAllSnapshots()

/**
Expand Down Expand Up @@ -821,7 +825,6 @@ export function createProjectionNode<I>({
updateLayout() {
if (!this.instance) return

// TODO: Incorporate into a forwarded scroll offset
this.updateScroll()

if (
Expand Down