7

I am using Jquery UI Drag and Drop ( http://jqueryui.com/demos/draggable ) together with https://github.com/furf/jquery-ui-touch-punch to map touch events over to mouse events. The whole drag and drop thing works fine so far.

The problem I have now is that I have a long list of draggable elements and I need to be able to scroll through the list on IPad as well... When I made the list elements draggable this won't work anymore.

I tried using the jqueryui provided constraints like distance and delay - but even then the scroll event seems to be totally disabled / overlayed with the drag event.

I probably need to write a custom function like "only if move to left at least 50 px make it draggable" or something.

Has anybody ever encountered a similar problem and is willing to share som thoughts about it? Are any other mobile web frameworks like Sencha or JQmobile equipped with such functionality?

Thanks in advance...

tmaximini
  • 8,403
  • 6
  • 47
  • 69

2 Answers2

4

It depends on your design of course, but you could try using handles.

Here is jQuery UI's documentation example :

<div id="draggable" class="ui-widget-content">
    <p class="ui-widget-header">drag with handle</p>
</div>
<div id="draggable2" class="ui-widget-content">
    <p>drag from content</p>
    <p class="ui-widget-header">not drag with handle</p>
</div>

$("#draggable").draggable({handle:"p"});
$("#draggable2").draggable({cancel:"p.ui-widget-header"});

Or at least the option cancel could give you a start.

http://jsfiddle.net/Dn9DX/

Jo VdB
  • 2,016
  • 18
  • 16
Gil Zumbrunnen
  • 1,062
  • 6
  • 17
  • thanks for your answer... i tried to make just a inside the
  • element draggable, but that is not the desired UI design. the whole
  • should be draggable and scrollable....
  • – tmaximini Aug 16 '12 at 14:08
  • Is your ul tag using 100% of the width of your iPad ? How about using something similar to what they did on the .slider() demo page here : http://jqueryui.com/demos/slider/#side-scroll This simple scrollbar example could be a neat workaround. Another workaround is to add a button to make the whole thing draggable or not, but again it depends on what your app is supposed to do... – Gil Zumbrunnen Aug 16 '12 at 14:14
  • nah, it only like 20% of the landcscape view. there are 2 scrollable lists with drag elements and 60% width canvas drop zone more or less – tmaximini Aug 17 '12 at 08:26