Gaurang Sondagar
Gaurang Sondagar

Reputation: 834

jQuery .draggable function not work on mobile device with touch

I am using below code but when try to use in mobile then try to drag with touch then it's not work. So can you please advice me how can i use with mobile touch.

 $(document).on('mouseover','.headerimage',function()
    {
        var y1 = $('#timelineBackground').height();
        var y2 =  $('.headerimage').height();
        $(this).draggable({
        scroll: false,
        axis: "y",
        drag: function(event, ui) {
        if(ui.position.top >= 0)
        {
        ui.position.top = 0;
        }
        else if(ui.position.top <= y1 - y2)
        {
        ui.position.top = y1 - y2;
        }
        },
        stop: function(event, ui)
        {
        }
    });
});

Thanks in advance.

Upvotes: 1

Views: 2142

Answers (1)

kelk
kelk

Reputation: 36

Touch devices do not support mouseover events. Check this for additional info: Preferred Alternative to OnMouseOver for touch

Edit: There seems to be a library made for this specific purpose http://touchpunch.furf.com/

Upvotes: 1

Related Questions