jQuery .draggable 功能不适用于带触摸的移动设备
jQuery .draggable function not work on mobile device with 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)
{
}
});
});
提前致谢。
触摸设备不支持 mouseover
事件。检查此以获取更多信息:
Preferred Alternative to OnMouseOver for touch
编辑:似乎有一个专门为此目的制作的库
http://touchpunch.furf.com/
我正在使用下面的代码,但是当尝试在移动设备中使用然后尝试通过触摸拖动时它不起作用。那么你能告诉我如何使用移动触摸吗?
$(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)
{
}
});
});
提前致谢。
触摸设备不支持 mouseover
事件。检查此以获取更多信息:
Preferred Alternative to OnMouseOver for touch
编辑:似乎有一个专门为此目的制作的库 http://touchpunch.furf.com/