jQuery Mobile Iphone 应用程序

标签 jquery ios html jquery-mobile draggable

我正在尝试为 iPhone 创建一个 HTML5 网络应用程序。我正在为此使用 jQuery Mobile。我的应用程序涉及在 Canvas 上绘图。它很像使用 Canvas 渲染草图的绘画应用程序。用户可以从任何方向在屏幕上滑动,应用程序应该能够找出位置,然后在这些点上画线。

jQuery Mobile 仅为滑动控件提供了以下一些基本事件,但我认为我需要对滑动进行更多控制,因为用户可以向任何方向滑动并且可以是任意像素长。另一方面,我应该能够捕捉到大部分的点,这样我就可以更清晰、更准确地想象这幅画。

tap
Triggers after a quick, complete touch event.
taphold
Triggers after a held complete touch event (close to one second).
swipe
Triggers when a horizontal drag of 30px or more (and less than 20px vertically) occurs within 1 second duration.
swipeleft
Triggers when a swipe event occurred moving in the left direction.
swiperight
Triggers when a swipe event occurred moving in the right direction.

在 Canvas 中为 iOs 应用程序创建绘图应用程序时,我是否应该遵循任何其他技术?任何帮助将不胜感激。

最佳答案

您在 jQuery Mobile 文档的事件页面上错过的一些事件是虚拟事件:http://jquerymobile.com/demos/1.0/docs/api/events.html

vmousedown
    Normalized event for handling touchstart or mousedown events

vmousemove
    Normalized event for handling touchmove or mousemove events

vmouseup
    Normalized event for handling touchend or mouseup events

vmousecancel
    Normalized event for handling touch or mouse mousecancel events

我会使用 vmousedown 事件开始跟踪光标的移动,使用 vmousemove 继续跟踪光标的路径,使用 vmouseup完成跟踪光标的移动。

一个简单的例子是:

//setup a variable to store the cursor's movement
var tracks = [];

//bind to the three events described above
$(document).bind('vmousedown vmousemove vmouseup', function (event) {

    //check to see what event is being fired
    if (event.type == 'vmousedown') {

        //if the `vmousedown` event is fired then reset the value of the `tracks` variable and add the first point to the variable
        tracks = [{ x : event.pageX, y : event.pageY}];
    } else if (event.type == 'vmousemove') {

        //if the `vmousemove` event is fired then add a new point to the `tracks` variable
        tracks.push({ x : event.pageX, y : event.pageY});
    } else if (event.type == 'vmouseup') {

        //if the `vmouseup` event is fired then the user is done drawing and you can draw their line for them
    }
});

关于jQuery Mobile Iphone 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8301203/

相关文章:

jquery - 输入字段无法运行(无法在其中输入文本)

javascript - 有没有办法等待一个Dom更新或者异步更新Dom?

ios - 在 MVC 中绘制模型 View 或 Controller 的 UIBezierPath 部分

ios - 在解除父 View 时隐藏登录 uiViewController

html - RoR ActionMailer 问题——无法同时发送纯文本和 HTML 电子邮件。

javascript - 如何将图像保持在页面的 50% 并包含其高度

javascript - 为什么 jQuery 为元素高度返回 null?

javascript - jQuery 数据(...)没有存储在 DOM 中?

ios - Swift 中字符串文字中的算术运算

html - 带指针事件的 iframe : none; but with a div inside it that has pointer-events: auto;