Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable jQuery UI drag and drop on Surface Pro tablet

As the title says, I'm trying to enable drag and drop on the Sufrace Pro 3 tablet.

Is drag and drop functionality even supported on these devices? If so, how would I go about enabling this feature? If not, how can I workaround this?

I'm trying to get jQuery UI's drag and drop feature to work. Here is a basic example I am trying to get working:

$( "#draggable" ).draggable();
#draggable {
    width: 200px;
    height: 200px;
    border: 1px solid;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<div id="draggable">
  <p>Drag me around</p>
</div>
like image 618
Azad Young Avatar asked Feb 11 '15 01:02

Azad Young


People also ask

How do you drag and drop in jQuery?

Using jQuery UI, we can make the DOM(Document Object Model) elements to drag anywhere within the view port. This can be done by clicking on the draggable object by mouse and dragging it anywhere within the view port. If the value of this option is set to false, it will prevent the DOM elements to be dragged .

How do I drag and drop on surface?

If you have a pen, the click and drag would be the same as the click and drag with a mouse. If you don't have a pen, you would need to use your finger to click on the icon you want to drag, and without lifting your finger on the screen, drag the icon to the position you want it to be. Hope this helps.

How does jQuery ui draggable work?

jQueryUI provides draggable() method to make any DOM element draggable. Once the element is draggable, you can move that element by clicking on it with the mouse and dragging it anywhere within the viewport.

How do I use draggable JS?

By default, only image and text can be draggable. To drag an image, you simply hold the mouse button down and then move it. To drag the text, you need to highlight some text and drag it in the same way as you would drag an image.


1 Answers

I had a similar issue a while back. You need to change the touch-action property of the desired elements to none. In this case, since you're using jQueryUI, you would apply this to the .ui-draggable/.ui-droppable elements.

You will also need to add the -ms vendor prefix, therefore you would use -ms-touch-action: none:

.ui-draggable, .ui-droppable {
    -ms-touch-action: none;
    touch-action: none;
}
like image 81
Josh Crozier Avatar answered Oct 15 '22 10:10

Josh Crozier