繁体   English   中英

Android与iphone上的jquery移动事件

[英]jquery mobile events on android vs. iphone

我是jquery mobile的新手。 我的问题是我需要捕获div上的vmousemove事件,因为我需要像在谷歌地图上的svg图像一样拖动这个div中的图像。

我在http://demo.baral.de/test/上有一个演示

我有3个设备: iphone iOS5三星选项卡上的Android 3.2HTC欲望的Android 2.2.2 当我“盘旋”在绿色div上时,我认为当我的手指触摸显示屏上的移动时会有很多“vmousemove”。

iphone开火了:

  • vmouseover
  • vmousedown
  • vmousecancel
  • 很多vmousemove
  • vmouseup

这似乎对我来说是完美的

Android 3.2开火:

  • vmouseover
  • vmousedown
  • vmousecancel
  • vmousemove

Android 2.2.2触发:

  • vmouseover
  • vmousedown
  • vmousecancel
  • vmousemove(1次)

在我完成移动并且我的手指离开显示器后它会发射

  • 很多vmousemove
  • vmouseup

这对于jquery mobile来说是“正常的”吗? 一个错误或只是错误的代码?

谢谢!

编码:

<!DOCTYPE html> 
<html> 
<head> 
    <title>My Page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head> 
<body> 
    <div data-role="page" data-position="fixed" id="wrapper">
        <div id="test" style="width: 200px; height: 200px; background-color: green"></div>
        <div id="footer" style="border: 1px solid black; width: 200px;">    
            <ul></ul>
        </div>
    </div>
    <script type="text/javascript">
        $("#wrapper").live('pageinit', function() {
            $("#test").bind('vmouseover vmousedown vmousemove vmouseup vclick vmousecancel', function (event) {
                $('#footer ul').append("<li>"+event.type+"</li>");
            });
        });
    </script>
</body>

我有类似的问题,并在回调函数的开头添加“event.preventDefault()”解决了它。 这里描述细节。

例:

$("#test").bind('vmouseover vmousedown vmousemove vmouseup vclick vmousecancel', function (event) {
     event.preventDefault();
     $('#footer ul').append("<li>"+event.type+"</li>");
});

这不是jquery-mobile的错误,当你想要在鼠标移动时实现某些东西时,无论如何你都可以这样做,因为它会被触发一次。 它可能是设计上的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM