Skip to content

Commit 0383b8b

Browse files
add fling start callback to y axis animation
EnhancedZoomStateImpl checks for fling start for both x and y axes
1 parent fd30c13 commit 0383b8b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

image/src/main/java/com/smarttoolfactory/image/zoom/EnhancedZoomStateImpl.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ open class BaseEnhancedZoomState constructor(
235235
val velocity = Offset(velocityTracker.x, velocityTracker.y)
236236
var flingStarted = false
237237

238-
val bounds = getBounds()
239238
launch {
240239
animatablePanX.animateDecay(
241240
velocity.x,
@@ -251,11 +250,16 @@ open class BaseEnhancedZoomState constructor(
251250
}
252251

253252
launch {
254-
val animationResult = animatablePanY.animateDecay(
253+
animatablePanY.animateDecay(
255254
velocity.y,
256-
exponentialDecay(
257-
absVelocityThreshold = 20f
258-
)
255+
exponentialDecay(absVelocityThreshold = 20f),
256+
block = {
257+
// This callback returns target value of fling gesture initially
258+
if (!flingStarted) {
259+
onFlingStart()
260+
flingStarted = true
261+
}
262+
}
259263
)
260264
}
261265
}

0 commit comments

Comments
 (0)