Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to drag drop images with touch screen device

Tags:

html

tablet

My HTML5 application lets you drag and drop images from another webpage. But when using PC in tablet mode I cannot seem to drag images, surely this must be possible in 2018?

If it really is not possible, what alternative mechanism can I use to allow User to use the image from another website?

like image 595
Paul Taylor Avatar asked Mar 28 '18 20:03

Paul Taylor


People also ask

How do I drag and drop with touch screen?

To drag. Put a finger on the desired point on the touch screen and slide the finger. You can move a file or change the window size with this motion.

How does drag and drop work on mobile?

Drag and drop feature allows you to take control of a html element by grabbing it and dragging and placing the element to a different location. To work with drag and drop features in Mobile Angular UI, you need to add the gestures module.

What is touch and drop?

: to not drink any alcohol He used to have a drinking problem but he hasn't touched a drop in years.


1 Answers

please look this:

var draggable = document.getElementById('draggable');
 draggable.addEventListener('touchmove', function(event) {
   var touch = event.targetTouches[0];

   // Place element where the finger is
   draggable.style.left = touch.pageX-25 + 'px';
   draggable.style.top = touch.pageY-25 + 'px';
   event.preventDefault();
 }, false);

also, Here is a tutorial: http://mobiforge.com/design-development/touch-friendly-drag-and-drop

Please let me know if it works or if you need any more help with that :)

Edit: Here is a jsfiddle with a test I built a while before. I've updated it with comments so you should see what's going on there. Maybe a JavaScript pro would want to hit me for this, but it's working for my purpose and I it seems to work. I haven't tested it in older browsers though, since it's a personal project and I'm not going the "optimizing for IE way" there

like image 129
k.swapnil Avatar answered Oct 29 '22 18:10

k.swapnil