Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slowing down motionLayout animation on swipe

I have motionLayout animation with the transition:

<Transition
        app:constraintSetEnd="@+id/end"
        app:constraintSetStart="@+id/start">
        <OnSwipe
            app:dragDirection="dragUp"
            app:dragScale="0.1"
            app:touchAnchorId="@id/my_scrollview" />
</Transition>

but the animation works too fast for me. I want to slow it down. I tried setting dragScale=0.1, maxAcceleration=1, maxVelocity=1 but it does'n affect the animation speed. How can I slow it down?

UPDATE: Issue was fixed in newer version of constraintlayout and seems to be working on "2.0.4"

like image 931
Rainmaker Avatar asked Sep 26 '19 19:09

Rainmaker


1 Answers

 <Transition
    motion:constraintSetEnd="@+id/end"
    motion:constraintSetStart="@id/start"
    motion:staggered="0.1"
    motion:duration="1000">

    <OnSwipe 
        motion:touchAnchorId="@id/view"
        motion:dragDirection="dragDown"
        motion:maxVelocity="20"
        motion:maxAcceleration="20"/>
 </Transition>

Short answer: modify duration, touchAnchorId, maxVelocity, maxAcceleration. turning up the velocity and acceleration and down the duration

Long answer

In general there are 2 phases to the animation of an on swipe When you finger is touching the "drag phase" when it is not "fling phase"

  1. Drag Phase The Drag Phase the animation tracks your finger. If you don't set a touchAnchorId then dragging across the whole screen takes you from start to end. If you set touchAnchorId the drag matches the velocity of the view you select. The drag of the distance the view moves takes you from start to end.
  2. Fling Phase The start of the fling the speed is set to the speed at the end of the Drag Phase. The goal becomes get to the start or end within the duration. accelerating or decelerating to a maximum velocity.

So for the above example if you drag to the middle and mouse up it will try to get you to the end within one second first accelerating at 20 (DDp/s2) to max v of 20 (Dp/ds) coast till the time is right such that it decelerates at 20 coming to a stop at the end.

Thinking of it as a car maxVelocity is the top speed. maxAcceleration is the 0-60 time. and duration is how much time you have to get there.

dragScale is a multiplier of the drag to progress calculated in the Drag Phase

I am simplifying many of other details but this is already getting complex.

like image 118
hoford Avatar answered Sep 22 '22 23:09

hoford