1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    10
    Vote Rating
    0
    Answers
    1
    Talamond is on a distinguished road

      0  

    Default Unanswered: Ignore Second Touch?

    Unanswered: Ignore Second Touch?


    I have some custom drag and droppable elements in my sencha touch app. A bug occurs when I'm dragging the item and I use another finger to touch the item I'm dragging (it seems a drop event occurs at that moment?). I was wondering if it is possible to just ignore any additional touches that occur on my object if I'm already dragging it.

    Thanks!

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    Answers
    25
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    Having a look at the source code for Ext.util.Draggable which you can see here: http://docs.sencha.com/touch/2.3.0/source/Draggable2.html#Ext-util-Draggable

    take
    a look at the initDragStart method. This sets .dragging = true; on the draggable. Likewise, when the drag ends, in onDragEnd, this property is set to false. So on your tap event listener, get the element's draggable and test this property. (use getDraggable() on the element to get the instance of Ext.util.Draggable). If it's true, then obviously you want to return out of the listener without doing anything.

    I know it's not ideal form to access what is a hidden property like this, but it's the best solution and perhaps the best fix might be for Sencha to expose this .dragging as a config on the Ext.util.Draggable, as it's a useful thing to be able to look at.
    I blog about Sencha Touch at www.senchatouchdev.com

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    10
    Vote Rating
    0
    Answers
    1
    Talamond is on a distinguished road

      0  

    Default


    I tried this solution, but the problem is that once second tap occurs, it also does a dragEnd event, which drops my element. I'm not sure how I can tell the difference between a second touch triggering the dragEnd event or the first touch actually releasing the element.

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    Answers
    25
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    I see what you mean. To be honest this is what I would do:

    1. Not worry about it too much. I would imagine most users would not change from 1 to 2 fingers during a drag and if they did, and the element dropped, they'd know not to do it again.

    2. File a bug in the bugs forum with Ext.util.Draggable. Native dragging behavior on iOS does allow the addition of a finger during a drag without cancelling it, so IMO Sencha should modify the behavior of draggable to match (at least on iOS - I didn't check what happens on Android)
    I blog about Sencha Touch at www.senchatouchdev.com

  5. #5
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,978
    Vote Rating
    132
    Answers
    334
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    You could try adding a buffer to the event.
    https://fiddle.sencha.com/#fiddle/2s8
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

Thread Participants: 2

Tags for this Thread