question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

initialSnap not working with dynamic value in snapPoints

See original GitHub issue

Hi, When I set

initialSnap={1}

with

const snapPoints = [sheetHeight, 0];

where sheetHeight comes from the props, the BottomSheet is already open. There is nothing I can do to change it, it seems so.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

2reactions
mitschabaudecommented, Feb 2, 2020

The general problem is that, when the sheet height dynamically changes, the positioning of the sheet (at snapPoint 0) is not adjusted – which makes the sheet seem to jump to a snap point value of (heightAfterDynamicChange - heightBeforeDynamicChange).

@kyryloz’s solution works only if the sheet does not have to be rendered at the lower height, but not if both heights represent actual content. I had this problem for a menu which could contain a different number of items, depending on the app state.

The only solution to the problem seems to be to make sure that the highest snap point stays constant. I.e., I would have three snap points, [maxHeight, dynamicHeight, 0], and if the menu opens, I snap to dynamicHeight (so the maxHeight snap point is not actually used). For the case that the user does drag the bottom sheet further up to the maxHeight snap point, I render white space of height (maxHeight - dynamicHeight) below the actual sheet content.

1reaction
BrtqKrcommented, Feb 20, 2020

There was a reported issue about unwanted behaviour when snapPoints are not in descending order inside the array (note has already been added to README). If the whole problem is connected to the initial value as @kyryloz stated, @mitschabaude’s solution should work, but it’s also worth to mention that if there’s more than one dynamic snapPoint you should remember to keep them ordered. I think that should be enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Input For Lines Starting with a Snap Not Working
Solved: When trying to draw a line starting with a snap, I want to spcify a defined length of the line with dynamic...
Read more >
Snapping to Points on Elements - MicroStation
Snapping to a point on an element at which that element is overlapped by another element(s) can be difficult, especially when working with...
Read more >
Using dynamic guides - Corel
For more information about snap points and snapping modes, see Snapping objects. As you drag an object along a dynamic guide, you can...
Read more >
React Native snapToOffsets for only one snap and then scroll ...
User a ternary operator in the snapToInterval property with the amount you want the for the first snap and what the snap should...
Read more >
Working with the Cursor-Snap System in Altium Designer
Covers user-definable grids and snap guides, as well as object and axis ... an enabled object snap point (and the Axes feature is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found