-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
[v4] screen resize events triggering animatedIndex change #1416
Comments
i will look into this shortly |
I tried with rotating the device, and it seems working as expected Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-06-25.at.12.38.08.mp4 |
tested on Screen.Recording.2023-06-25.at.12.40.52.mov |
@gorhom thanks for your response! I'm going to upgrade to v5 and double check. If I'm still seeing an issue there I'll reopen. |
@gorhom sadly this issue does still happen in v5. It's much better in v5 than in v4 (v4 even the slightest resize caused it). I've created a repro example here and I also have a video of what I'm talking about here: bottom-sheet-close.movYou really have to quickly resize the window in order to see it now, however I think such resizes are fairly practical when considering things like entering and exiting fullscreen. Like I said before, it's definitely way better than before as before even a 1px nudge would cause a close. I think the two conditions for a index changing are:
EDIT: I can confirm that the most practical use-case for this is if a user has a window of a smaller size and has the bottom sheet open close to the bottom (like in the video) and then they enter and then exit fullscreen. Upon exit, the bottom sheet closes. The second half of my video demonstrates that fast resizes can cause a closed bottom sheet to temporarily reveal itself. This definitely is a bit of a "nit", but it can be undesirable if the state of a closed player is "ugly" or "confusing" because it has no content loaded. This point I bring up as more food for thought. The thing I'm most concerned with is the closing behavior. Let me know your thoughts! I'm happy to pitch in and write some code. |
Another way to reproduce this on native Android is by opening the keyboard when the bottom-sheet is open (and sufficiently close to the bottom of the screen). The default configuration for android is |
…nimatedIndex of the bottomsheet fix gorhom#1416
@jspizziri thanks for providing a repo with setup to reproduce the issue. I am just wondering if this issue also occurs on apps too ? cause resizing the container with the speed that you show is not realistic to me, and if that is the case then we need to have a solution only for web and not effect the apps. |
@gorhom Yes it does happen in apps too. One way I've gotten it to reproduce is by opening an android keyboard when the sheet is open and docked close to the bottom. I think I document that somewhere, it might be on the PR I sent. |
@jspizziri could i use https://github.com/jspizziri/rna-test/blob/main/src/pages/index.tsx to repo the issue on Android ? |
That's a web build on nextjs, so it would need to be modified to view on native. If you add a text input on the underlying view that pops a keyboard in a native project that should do it. I can try to send you an example app but it might take a bit. |
@gorhom I realize now I might've misunderstood your question. You could basically copy the contents of that index file and strip out all the NextJS specific stuff and you should be able to reproduce it on Android yes. Make sure that you have |
@gorhom if it's helpful I just created a repo in the example diff --git a/example/app/src/screens/basic/BasicExamples.tsx b/example/app/src/screens/basic/BasicExamples.tsx
index 8988e3c..7ac3150 100644
--- a/example/app/src/screens/basic/BasicExamples.tsx
+++ b/example/app/src/screens/basic/BasicExamples.tsx
@@ -24,7 +24,7 @@ const createExampleScreen = ({ type, count = 25 }: ExampleScreenProps) =>
//#endregion
//#region variables
- const snapPoints = useMemo(() => ['25%', '50%', '90%'], []);
+ const snapPoints = useMemo(() => [60, '100%'], []);
const enableContentPanningGestureButtonText = useMemo(
() =>
enableContentPanningGesture Here's a video of it happening in the example app with the above changes: Screen.Recording.2023-07-21.at.2.14.25.PM.movAs I mentioned elsewhere it frequently happens as the result of a screen maximize/minimize. My PR does in fact seem to fix it, I just don't love the way it works. |
I think this also seems to be happening on Android. @gorhom @jspizziri Steps to reproduce -
When the TextInput is blurred, that's when the flickering happens. The animatedIndex.value becomes 0 for a split second, which probably happens because the animatedPosition.value is reduced by the size of the keyboard, this makes the bottom sheet visible for a split second. |
@fluorescent23 could you provide a sample repo code ? |
This is actually the same bug as in #1356 , only triggered by other actions than keyboard appearance. And seems to actually be cause by a change introduced in react-native-reanimated v3. See my findings in about why this happens in #1356 (comment) and #1356 (comment). |
This issue might be related to #516 as well. |
Bug
When a resize event occurs such as a screen rotation (in native) or a window resize (in web) the bottom sheet index can change suddenly. This seems to be due to
animatedContainerHeight
being used in the calculation ofanimatedIndex
.Environment info
Steps To Reproduce
Web
Mobile
I haven't tested this on mobile but theoretically it should happen there too.
Describe what you expected to happen:
A window/screen resize should not result in a change in the
animatedIndex
Reproducible sample code
N/A
Notes
I've done a little exploration on fixing this but I'm not super happy with any of my approaches or results. I've effectively tried to set a property in the component when a resize reaction takes place and then adding a conditional to check if a resize event is the responsible for triggering a recalc on the
animatedIndex
property.If I could get some direction from someone who knows more about the library and the best path forward I'd happily do the implementation and submit a PR!
The text was updated successfully, but these errors were encountered: