From 5be780de7d1c5da36ed51ae5c81d1bd8812f5aab Mon Sep 17 00:00:00 2001 From: Patryk Goworowski Date: Wed, 18 Dec 2024 18:57:57 +0100 Subject: [PATCH] Fix nested scrolling when horizontal scroll is disabled --- .../vico/compose/cartesian/TouchEvent.kt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/cartesian/TouchEvent.kt b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/cartesian/TouchEvent.kt index c41793ca5..77b977864 100644 --- a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/cartesian/TouchEvent.kt +++ b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/cartesian/TouchEvent.kt @@ -17,7 +17,6 @@ package com.patrykandpatrick.vico.compose.cartesian 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 @@ -47,6 +46,8 @@ internal fun Modifier.chartTouchEvent( when (event.type) { PointerEventType.Press -> setTouchPoint(event.changes.first().position.point) PointerEventType.Release -> setTouchPoint(null) + PointerEventType.Move -> + if (!isScrollEnabled) setTouchPoint(event.changes.first().position.point) } } } @@ -55,21 +56,6 @@ internal fun Modifier.chartTouchEvent( Modifier } ) - .then( - if (!isScrollEnabled && setTouchPoint != null) { - pointerInput(setTouchPoint) { - detectHorizontalDragGestures( - onDragStart = { setTouchPoint(it.point) }, - onDragEnd = { setTouchPoint(null) }, - onDragCancel = { setTouchPoint(null) }, - ) { change, _ -> - setTouchPoint(change.position.point) - } - } - } else { - Modifier - } - ) .then( if (isScrollEnabled && onZoom != null) { pointerInput(setTouchPoint, onZoom) {