react-modal-sheet icon indicating copy to clipboard operation
react-modal-sheet copied to clipboard

How to get current active snap?

Open nickbyte opened this issue 4 years ago • 4 comments

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

nickbyte avatar Oct 03 '21 10:10 nickbyte

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}

Guiw5 avatar Oct 11 '21 18:10 Guiw5

@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 🤔

Temzasse avatar Jan 23 '22 19:01 Temzasse

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

slellampati avatar Mar 18 '22 15:03 slellampati

@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

Guiw5 avatar Apr 07 '22 05:04 Guiw5

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?

AbBiz21 avatar Aug 24 '22 16:08 AbBiz21

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

Temzasse avatar Oct 07 '22 18:10 Temzasse