From 90130a7bfb75921821d716b8e8f5d7e49ac51690 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Sun, 12 Nov 2023 23:59:49 +0800 Subject: [PATCH] fix: use absolute delta by scale in Switch --- .../kotlin/com/highcapable/flexiui/component/Switch.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt index d86d933..569dfac 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt @@ -153,9 +153,10 @@ fun Switch( orientation = Orientation.Horizontal, interactionSource = interactionSource, state = rememberDraggableState { delta -> - absOffsetX += delta + val absDelta = delta * animatedScale + absOffsetX += absDelta when { - absOffsetX in 0f..maxOffset -> offsetX += delta + absOffsetX in 0f..maxOffset -> offsetX += absDelta absOffsetX < 0f -> offsetX = 0f absOffsetX > maxOffset -> offsetX = maxOffset }