How reset detectHorizontalDragGestures

23 Views Asked by At

I use code for listen swipe

            Card(
                modifier = Modifier
                    .offset { IntOffset(offset.roundToInt(), 0) }
                    .pointerInput(Unit) {
                        detectHorizontalDragGestures(
                            onDragEnd = { offset = 0f },
                            onHorizontalDrag = { change, dragAmount ->
                                offset += (dragAmount / density) * sensitivityFactor
                                when {
                                    offset > swipeThreshold -> dismissRight = true
                                    offset < -swipeThreshold -> dismissLeft = true
                                }
                                if (change.positionChange() != Offset.Zero) change.consume()
                            }
                        )
                    }
            ) {}

I also keep track dismissLeft

LaunchedEffect(dismissLeft) {
// Stop drag
}

How can I reset the animation (so that the card stops following my finger)?

0

There are 0 best solutions below