Reputation: 33
Could anyone please explain what MotionLayout's onSwipe parameters touchAnchorId and touchAnchorSide do? This is what documentation says about touchAnchorId
View that is being moved by the swipe.
That doesn't make sense to me as swiping on MotionLayout doesn't move a single view. Swiping progresses transition between starting constraintSet and ending constraintSet. I thought initially that touchAnchorId would specify a view that user will have to drag to progress animation but this isn't a case and MotionLayout developer team introduced touchRegionId parameter for that. It's also unclear to me what touchAnchorSide is supposed to do as I don't see any difference when changing its value.
Upvotes: 2
Views: 802
Reputation: 5323
onSwipe Move progress from 0 to 1 along a direction(dragDirection=) horizontal (dragRight/Left/StartEnd) or vertical (dragUp/Down)
If I drag my finger a 100 pixels along the screen how much does it move from 0 to 1? That is the main question most of the other argument answer. with out an anchor it uses the full length of the layout.
But if you are making a pull out draw that is excessive. You could adjust it with dragScale. But how much? The pull may vary based on constraints fonts many things.
Many times you want it to act as if you are pulling a view or a side of a view. In which case you ned to the View (touchAnchorId) and the side of the view (touchAnchorSide)
Sometimes you want to limit the region in which the swipe will work In which case you can use limitBoundsTo.
Much of the rest of the flags are bout what to do when you lift your finger. There is much more subtly in all the use-cases it is designed to support.
Upvotes: 2