Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 78ab37a

Browse files
committed
Updated Material2DAnimationSpec
It's now possible to provide a second easing curve to handle interpolations for the 3rd and 4th variable. This is usefuld for example when interpolating bounds, where the first two variables may correpond to the location and the last two variables correspond to the dimensions and you may want different easing curves for each pair.
1 parent 3929206 commit 78ab37a

File tree

2 files changed

+296
-129
lines changed

2 files changed

+296
-129
lines changed

demoProjects/Drag2DCompose/app/src/main/java/android/support/drag2d/Material2DMotionPreview.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package android.support.drag2d
1818

19-
import android.support.drag2d.compose.Material2DAnimationSpec
19+
import android.support.drag2d.compose.materialVelocity2D
2020
import android.support.drag2d.lib.MaterialEasing
2121
import android.support.drag2d.lib.MaterialVelocity
2222
import androidx.compose.animation.core.Animatable
@@ -144,10 +144,9 @@ fun Material2DMotionPreview() {
144144
touchUpIndex.value = accumulator.size - 1
145145
val initialVelocity = velocityTracker.calculateVelocity()
146146

147-
// Velocity tracker has a tendency to fail measuring velocity
148147
offset.animateTo(
149148
targetValue = Offset.Zero,
150-
animationSpec = Material2DAnimationSpec(
149+
animationSpec = materialVelocity2D(
151150
duration.value.roundToInt(),
152151
maxVelocity.value,
153152
maxAcceleration.value,

0 commit comments

Comments
 (0)