B4A Class Draggable View [Edited - Swipe Gesture]

Hi everyone, this class is an edit of this class from Erel:
https://www.b4x.com/android/forum/threads/classes-are-soon-coming.18395/

I've done some changes to achieve an animated "Swipe gesture (left to right)"
  • If you swipe all the way right to the trigger point, you can trigger an event, definable in the class. (I will modify it soon)
  • B4X:
    ...
    If (panel1.Left+panel1.Width >= Tpoint) Then
                      
                        CallSub(Main, "Swipe_Output") '********************************* CHANGE THIS CALL TO CALL YOUR SUB
                      
                        innerView.SetLayoutAnimated(150,LeftPoint,innerView.Top,innerView.Width,innerView.Height)
    ...

  • If you release before reaching the trigger point the view automatically goes back to the original spot.

  • You can set the triggerPoint

  • You can't swipe right to left (but if you want, you can apply some changes)

    B4X:
    ...
    If x > downx Then 'Write "<" if you want swipe right to left
    ...

    And

    B4X:
    ...
    If (panel1.Left+panel1.Width >= Tpoint) Then 'write "(panel1.Left <= Tpoint)" to swipe right to left
    ...
Like so:
ezgif.com-optimize(4).gif



Read
the notes i wrote in the code!
 

Attachments

  • DraggableView (Swipe Gesture).zip
    11 KB · Views: 423
Last edited:
Top