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

How to get current active snap? #50

Closed
nickbyte opened this issue Oct 3, 2021 · 6 comments
Closed

How to get current active snap? #50

nickbyte opened this issue Oct 3, 2021 · 6 comments

Comments

@nickbyte
Copy link

nickbyte commented Oct 3, 2021

I am trying to adjust the wrapping container height based on which is the active current point, onSnap, returns negative values. So hard to identify which is the active snap

@Guiw5
Copy link

Guiw5 commented Oct 11, 2021

you have this handler on props

onSnap={snapIndex => console.log('> Current snap point index:', snapIndex) }
is the index from snapPoints array

snapPoints={[600, 400, 100, 0]}
initialSnap={1}

@Temzasse
Copy link
Owner

@nickbyte can you provide a repro of this issue in CodeSandbox? Or did you figure it out?

Your problem might be related to you changing the container height which will probably mess with the snap point calculations within the library 🤔

@slellampati
Copy link

I have the same problem. It gives a valid snapoint index on load but after dragging, it always gives -1.

@Guiw5
Copy link

Guiw5 commented Apr 7, 2022

@Temzasse I found the issue:
I was using your example from
https://github.com/Temzasse/react-modal-sheet/blob/master/example/components/SnapPoints.tsx
but if you change the snapPoints all to percentages like:
const snapPoints = [0.9, 0.6, 0.3, 0];

And just appear when dragging in responsive view
codesandbox

@AbBiz21
Copy link

AbBiz21 commented Aug 24, 2022

I am having the same problem, I used the following props
<Sheet
snapPoints={[0.925, 0.53, 0.19]}
initialSnap={2}
onSnap={(snapIndex) => {
console.log(snapIndex);
}} .../>

but it is giving the actual snap index on load only. Otherwise, it returns -1.
is there any way I can get the current snap index?

@Temzasse
Copy link
Owner

Temzasse commented Oct 7, 2022

Thanks for reporting this 🙏🏻 This should be fixed in version 1.6.1 🙂

@Temzasse Temzasse closed this as completed Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants