Grow your CSS skills. Land your dream job.

How to get HTML5 drag and drop work on touch devices

  • # March 2, 2013 at 6:48 pm

    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

    # March 2, 2013 at 7:40 pm

    This works http://touchpunch.furf.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".