New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OnSwipe] touchAnchor moves faster than cursor / touchRegion ignored after first touch #229
Comments
"touchAnchorSide" has no "middle" it can only be top/left/right/bottom/start/end |
Thanks @jafu888 ! However, I'm getting still the same behaviour with this <OnSwipe
app:autoCompleteMode="spring"
app:dragDirection="dragEnd"
app:dragThreshold="0"
app:onTouchUp="autoCompleteToStart"
app:springBoundary="bounceStart"
app:springDamping="40"
app:springMass="1"
app:springStiffness="750"
app:springStopThreshold="5"
app:touchAnchorId="@id/dragHandle"
app:touchAnchorSide="end"
app:limitBoundsTo="@id/dragHandle" /> Also, I just searched for your suggested fixes and couldn't really find any reason in the source code for them to work. Am I missing something?
|
Layout
MotionScene
v1.mp4 |
I put a small example above. |
Sorry for all the confusion. Here is my full Layout / ConstraintSet: Layout<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="44dp"
app:layoutDescription="@xml/quick_buy"
tools:layout_gravity="center_vertical">
<View
android:id="@+id/master"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@drawable/quickbuy_background" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textQuickBuy"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@drawable/quickbuy_ripple"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:paddingHorizontal="10dp"
android:text="Quick buy"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="14sp"
app:drawableStartCompat="@drawable/ic_quickbuy"
app:fontFamily="@font/catamaran_bold" />
<View
android:id="@+id/track"
android:layout_width="0dp"
android:layout_height="32dp"
android:background="@drawable/quickbuy_progress" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/quickbuy_ripple"
android:padding="6dp"
app:srcCompat="@drawable/ic_cancel"
app:tint="@color/white" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/state"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:text="Ziehen zum Bestellen"
android:textColor="@color/white"
android:textSize="14sp"
app:fontFamily="@font/catamaran_bold" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/dragHandle"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="@drawable/quickbuy_thumb"
android:elevation="4dp"
android:outlineProvider="background"
android:scaleType="center"
app:srcCompat="@drawable/quickbuy_handle" />
</androidx.constraintlayout.motion.widget.MotionLayout> MotionScene<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
android:id="@+id/transitionStartToDragging"
app:constraintSetEnd="@id/stateDragStart"
app:constraintSetStart="@id/stateStart"
app:duration="300"
app:motionInterpolator="easeOut">
<OnClick
app:clickAction="transitionToEnd"
app:targetId="@+id/textQuickBuy" />
</Transition>
<Transition
android:id="@+id/transitionDraggingToStart"
app:constraintSetEnd="@id/stateStart"
app:duration="300"
app:motionInterpolator="easeOut">
<OnClick
app:clickAction="transitionToEnd"
app:targetId="@+id/cancel" />
</Transition>
<Transition
android:id="@+id/transitionDrag"
app:constraintSetEnd="@id/stateDragEnd"
app:constraintSetStart="@id/stateDragStart"
app:duration="300"
app:motionInterpolator="cubic(0.34, 1.56, 0.64, 1)">
<OnSwipe
app:autoCompleteMode="spring"
app:dragDirection="dragEnd"
app:dragThreshold="0"
app:limitBoundsTo="@id/dragHandle"
app:onTouchUp="autoCompleteToStart"
app:springBoundary="bounceStart"
app:springDamping="40"
app:springMass="1"
app:springStiffness="750"
app:springStopThreshold="5"
app:touchAnchorId="@id/dragHandle"
app:touchAnchorSide="end" />
</Transition>
<ConstraintSet android:id="@+id/stateStart">
<Constraint
android:id="@+id/master"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="@id/textQuickBuy"
app:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@+id/textQuickBuy"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/master"
app:layout_constraintStart_toStartOf="@id/master"
app:layout_constraintTop_toTopOf="@id/master"
app:layout_constraintWidth="wrap_content_constrained" />
<Constraint
android:id="@+id/dragHandle"
android:layout_width="36dp"
android:layout_height="36dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/track"
app:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/track"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginEnd="6dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/master"
app:layout_constraintEnd_toEndOf="@id/master"
app:layout_constraintStart_toStartOf="@id/master"
app:layout_constraintTop_toTopOf="@id/master" />
<Constraint
android:id="@+id/cancel"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/state"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/track"
app:layout_constraintEnd_toEndOf="@id/track"
app:layout_constraintStart_toStartOf="@id/track"
app:layout_constraintTop_toTopOf="@id/track" />
</ConstraintSet>
<ConstraintSet android:id="@+id/stateDragStart">
<Constraint
android:id="@+id/master"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@+id/textQuickBuy"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/master"
app:layout_constraintStart_toStartOf="@id/master"
app:layout_constraintTop_toTopOf="@id/master" />
<Constraint
android:id="@+id/dragHandle"
android:layout_width="36dp"
android:layout_height="36dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/track"
app:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/track"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginEnd="6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/cancel"
app:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/cancel"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/state"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/track"
app:layout_constraintEnd_toEndOf="@id/track"
app:layout_constraintStart_toStartOf="@id/track"
app:layout_constraintTop_toTopOf="@id/track" />
</ConstraintSet>
<ConstraintSet
android:id="@+id/stateDragEnd"
app:deriveConstraintsFrom="@id/stateDragStart">
<Constraint
android:id="@+id/dragHandle"
android:layout_width="36dp"
android:layout_height="36dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/track"
app:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
</MotionScene> |
Short answer - set : I will try and explain. Other things to consider.... BounceStart |
Thank you so much for trying to help!
Unfortunately, this didn't change anything.
I prefer the wall effect. But may change it later to overshoot, if our Designer likes it more. Here is how the View works now (code same as above, but with screen-20210525-001854.2.mp4
|
Increase the threshold (or increase the dampening ) till it stops quickly. |
Thanks for showing the video it helps. |
if you move the transition "transitionDrag" to the top of the list of transitions. it works! Note: the initial state (ConstraintSet) of a motion layout is the starting state of the first Transition. So in your original configuration you started off in "stateStart" (coming from transitionStartToDragging) There is a bug here (It should not drop into the transitionDrag.) But fixing it will brake you. I am confused as to what exactly is the interaction you were hoping for with transitionStartToDragging and its stateStart |
I just tried We may need to split this ticket to track all three bugs separately... The View should work like this (and did in Version
In step 2, the user can click the X-Button to revert back to the 'Quick Buy' state. ( I made a comparison of version
|
Yes split it.
Alternative provide sample code showing how you are driving system. Springs are fundamentally different in that they are non deterministic as to when they end but they should end. |
Okay, I'm closing this issue now. Replaced by |
How i can increate touch move speed like on screen-20210525-001854.2.mp4? |
I am experiencing a few bugs in the current
MotionLayout
,touchAnchorId
(Have the drag act as if it is moving the "touchAnchorSide" of this object), but the AnchorView moves faster than my fingertouchRegionId
(Limits the region that the touch can be start in to the bounds of this view (even if the view is invisible)), but after the first touch up, the wholeMotionLayout
reacts to the swipeI already tried using
app:dragScale="1"
, but it had no effect. Also, I triedapp:motionInterpolator="linear"
on theTransition
, but it didn't have an effect either.This happens on ConstraintLayout version
2.1.0-beta02
. The stable version2.0.4
works fine.The MotionScene is quite big. This is the relevant
Transition
:Edit:
layout_width="wrap_content"
doesn't work in this scenario either. ("Quick Buy" should be a single line)The text was updated successfully, but these errors were encountered: