SwipeOffset and SwipeThreshold

2 posts, 0 answers
  1. Ivo
    Ivo avatar
    4 posts
    Member since:
    May 2016

    Posted 30 Mar Link to this post

    Hi,

    recently, i detected some strange behavior on the swiping-feature of the telerik list. I have definded a list im Xaml like the following one:

    <telerikDataControls:RadListView
             IsItemSwipeEnabled="True"
             SwipeThreshold="300"
             SwipeOffset="300, 0, 300, 0"
             ItemSwipeCompleted="OnItemSwipeCompleted">
          ....
    </telerikDataControls:RadListView >

     

    I now discovered, that the SwipeOffset seems to be ignored in UWP and Android, as I am able to swipe the ViewCell-Content to the left (or right) without stopping at the defined offset. As i defined some buttons in as swipe background (one button left, one button right), i am able to see both buttons at the same time as the swipe does not stop.I intended to either see the left button by swiping right or see the right button by swiping left - but I did not to expect seeing both buttons as there is no swipe stop. In iOS all seems to work fine, as the swipe stops at the above defined thickness (SwipeOffset)

    Another strange thing, I discovered is, that the ItemSwipeCompleted event is always triggered - regardless of which value is set in SwipeThreshold. Again - this issue does only evolve in Android / UWP -> in iOS all seems fine :)

    So far I use a workaround for "using" the SwipeThreshold

    public void OnItemSwiping(object sender, ItemSwipingEventArgs e)
    {
            var list = sender as Telerik.XamarinForms.DataControls.RadListView;
            var threshold = list.SwipeThreshold;
            if (Math.Abs(e.Offset) < threshold //Workaround, to not accept swiping, when it does not meet the Threshold
            {
                    list.EndItemSwipe();
                    return;
            };
    }

     

    Is there anything, we I do about the both issues? As I found a workaround for the SwipeThreshold, I am especially interested in a solution for "stopp" swiping at the SwipeOffset.

    Again thank you very much in advance!

    Best regards,

    Ivo

  2. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    586 posts

    Posted 04 Apr Link to this post

    Hi Ivo,

    Thank you for contacting us.

    The observed behavior is caused by differences in the implementation of this feature in the native controls. The SwipeThreshold defines the minimum distance required for an item to travel in order to remain swiped. The SwipeOffset defines the offset at which an item will be positioned when it is released. The SwipeEnded event occurs when the item is released.

    We do not have an API to restrict the swipe offset on all platforms. I have logged a feature request in our feedback portal.

    As for the issue with ItemSwipeCompleted event, your code snippet looks a bit weird:
    Math.Abs(e.Offset) < threshold

    This should cancel the swipe gesture immediately. Nevertheless, there is an issue with this setup on iOS - the ItemSiping event continues after EndItemSwipe() is called. I have logged a bug in our feedback portal where you can track its progress. I have updated your Telerik points for bringing this issue to our attention.

    Could you please elaborate a bit on your scenario and the observed behavior in case we have missed something.

    I look forward to your reply.

    Regards,
    Rosy Topchiyska
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top