简体   繁体   English

Android与iphone上的jquery移动事件

[英]jquery mobile events on android vs. iphone

i´m new with jquery mobile. 我是jquery mobile的新手。 My problem is that I need to catch the vmousemove events on a div because I need to drag images within this div like the svg images on google maps. 我的问题是我需要捕获div上的vmousemove事件,因为我需要像在谷歌地图上的svg图像一样拖动这个div中的图像。

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

I got 3 devices: iphone iOS5 , Android 3.2 on Samsung tab and Android 2.2.2 on HTC desire . 我有3个设备: iphone iOS5三星选项卡上的Android 3.2HTC欲望的Android 2.2.2 When I "hover" over the green div I thought there would be a lot of "vmousemove" while my finger touches an moves on the display. 当我“盘旋”在绿色div上时,我认为当我的手指触摸显示屏上的移动时会有很多“vmousemove”。

The iphone fires: iphone开火了:

  • vmouseover vmouseover
  • vmousedown vmousedown
  • vmousecancel vmousecancel
  • a lot of vmousemove 很多vmousemove
  • vmouseup vmouseup

This seems to be perfect to me 这似乎对我来说是完美的

The Android 3.2 fires: Android 3.2开火:

  • vmouseover vmouseover
  • vmousedown vmousedown
  • vmousecancel vmousecancel
  • vmousemove vmousemove

The Android 2.2.2 fires: Android 2.2.2触发:

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

and after I finished the move and my finger leaves the display it fires 在我完成移动并且我的手指离开显示器后它会发射

  • a lot of vmousemove 很多vmousemove
  • vmouseup vmouseup

Is this "normal" for jquery mobile? 这对于jquery mobile来说是“正常的”吗? A bug or just the wrong code? 一个错误或只是错误的代码?

Thanks! 谢谢!

The code: 编码:

<!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>

I had similar problem and adding "event.preventDefault()" at the beginning of the callback function solved it. 我有类似的问题,并在回调函数的开头添加“event.preventDefault()”解决了它。 Details of are described here . 这里描述细节。

Example: 例:

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

This is not a bug with jquery-mobile, when you want to achieve something when mouse moves, you can do it anyway as it is getting fired once. 这不是jquery-mobile的错误,当你想要在鼠标移动时实现某些东西时,无论如何你都可以这样做,因为它会被触发一次。 It might be by design. 它可能是设计上的。

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

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