【问题标题】:jQuery .draggable function not work on mobile device with touchjQuery .draggable 功能在触摸移动设备上不起作用
【发布时间】:2023-03-05 03:03:01
【问题描述】:

我正在使用下面的代码,但是当尝试在移动设备中使用然后尝试通过触摸拖动时,它不起作用。所以你能告诉我如何使用移动触摸。

 $(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)
        {
        }
    });
});

提前致谢。

【问题讨论】:

    标签: jquery mobile drag-and-drop touch


    【解决方案1】:

    触控设备不支持mouseover 事件。检查此以获取更多信息: Preferred Alternative to OnMouseOver for touch

    编辑:似乎有一个为此特定目的而制作的库 http://touchpunch.furf.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      • 2016-07-12
      • 1970-01-01
      相关资源
      最近更新 更多