treehouse : what would you like to learn today?
Web Design Web Development iOS Development

How to get HTML5 drag and drop work on touch devices

  • Hi

    I have started making a game with the HTML5 drag and drop. I tried it on my iPad and iPhone and did not work. This is a small part of my existing code;

    $('.characters').bind('dragstart', function(e){
      e.dataTransfer.setData('text', $(this).attr('id'));
      position = $(this).parent().attr('id');
      if ($(this).attr('class') == turn) {
        console.log('carry on');
      }else( console.log("it is not your turn") );
    });
    

    In order to at touch events. Would I have to manipulate the above code so that it works for both, mouse and touch. Or to I have to create the touch script separately from the above. Or should I not use the HTML5 API at all and go for a js library that might have all the required gestures I need.

    This project started as a way for me to learn HTML5 drag and drop, so is this API limited only for the mouse?

    hope you can put me in the right direction

    Thanks