Skip to content

Commit

Permalink
The marker remains visible after touching the graph. The marker label…
Browse files Browse the repository at this point in the history
… can be set to null.
  • Loading branch information
andrey-ananiev committed Dec 5, 2023
1 parent 0427cec commit f8f9d96
Showing 1 changed file with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}
}
Expand All @@ -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) {
Expand Down

0 comments on commit f8f9d96

Please sign in to comment.