Repository navigation
Allow stacking sheets with the iOS modal effect - #242
Merged
Merged
Conversation
Author
Owner
|
Hey @alesmraz 👋🏻 Thank you for this awesome PR! I'm a bit swamped at work currently but I will review this as soon as I have a bit more capacity and free time 🙂 |
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #150
Issue
Opening a sheet on top of another sheet had no way to push the underlying sheet back the way the app root is pushed back by
modalEffectRootId. Pointing the second sheet'smodalEffectRootIdat the first sheet didn't work since the effect writestransformdirectly on the element and the sheet container'stransformis controlled by Motion.Solution
modalEffectRootIdcan now also be theidof another sheet. When it resolves to a sheet, the effect is applied to that sheet's container with the standalonescaleandtranslateCSS properties, so Motion keepstransformfor itself. The underlying sheet ends up in the same position as the app root does after its own modal effect (top edge, width and horizontal inset match), lifted by at most 10px so sheets with a smaller height don't jump to the top. There is no CSS transition for the underlying sheet since it follows theyvalue of the sheet on top frame by frame, which keeps both in sync while dragging and closing. Cleanup only removes what the effect added, so the body background andoverflowowned by the root effect are untouched.Sheets can be stacked any number of levels deep by always pointing
modalEffectRootIdto the sheet directly underneath.Also changed
useMeasuretooffsetSize: trueso a scaled sheet still measures its layout height.idlands on the sheet root elementTested in Chromium at phone and desktop sizes: opening/closing each level, dragging the top sheet, closing the underlying sheet while a stacked one is open, and the existing modal effect examples (snap-points, apple-music, slack-message) still clean up as before.
stacked-sheets-demo.mov