diff --git a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/extension/ModifierExtensions.kt b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/extension/ModifierExtensions.kt index 7043bff27..143334f31 100644 --- a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/extension/ModifierExtensions.kt +++ b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/extension/ModifierExtensions.kt @@ -17,7 +17,6 @@ package com.patrykandpatrick.vico.compose.extension import androidx.compose.foundation.gestures.Orientation -import androidx.compose.foundation.gestures.detectHorizontalDragGestures import androidx.compose.foundation.gestures.scrollable import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset @@ -42,17 +41,18 @@ internal fun Modifier.chartTouchEvent( if (setTouchPoint != null) { pointerInput(setTouchPoint) { awaitPointerEventScope { - var isDragStarted = false + var isNoDrag = true while (true) { val event = awaitPointerEvent() when (event.type) { - PointerEventType.Move -> isDragStarted = true - PointerEventType.Scroll -> isDragStarted = true + PointerEventType.Press -> setTouchPoint(null) + PointerEventType.Move -> isNoDrag = false PointerEventType.Release -> { - if (!isDragStarted) setTouchPoint( - event.changes.first().position.point - ) - isDragStarted = false + if (isNoDrag) { + setTouchPoint(event.changes.first().position.point) + } else { + isNoDrag = true + } } } } @@ -62,19 +62,6 @@ internal fun Modifier.chartTouchEvent( Modifier }, ) - .then( - if (!isScrollEnabled && setTouchPoint != null) { - pointerInput(setTouchPoint) { - detectHorizontalDragGestures( - onDragStart = { }, - onDragEnd = { }, - onDragCancel = { }, - ) { _, _ -> } - } - } else { - Modifier - }, - ) .then( if (isScrollEnabled && onZoom != null) { pointerInput(setTouchPoint, onZoom) {