What's the purpose of touchAnchorSide in MotionLayout?

Viewed 716

I don't understand what is the purpose of touchAnchorSide in MotionLayout.

I have this path and it works fine with this code:

<OnSwipe motion:touchAnchorId="@id/view" motion:dragDirection="dragRight"/>

enter image description here

1 Answers

I'm pretty late with the answer, but think it can be helpfull for somebody here. So motion:touchAnchorSide starts animation when your finger cross selected side of the view For example

motion:touchAnchorSide="top"
<!--animation starts working when touch X > view.x-->

motion:touchAnchorSide="bottom"
<!--animation starts working when touch X > (view.x + view.height)-->

motion:touchAnchorSide="left"
<!--animation starts working when touch Y > view.y-->

motion:touchAnchorSide="right"
<!--animation starts working when touch & > (view.y + view.width)-->

Look at the picture to understand side positions, brown line is a touchAnchorSide where animation starts.

enter image description here

Also you can replace motion:touchAnchorSide and motion:touchAnchorId with single motion:touchRegionId which need view id and track all sides at the same time.

Related