Mac上Webkit中手势的Javascript事件?
是否可以在Mac桌面上的Webkit上用Javascript获取手势事件,例如3个手指的回扫?我在谷歌上搜索了几次,什么也找不到。否则,我想我可以将它们从Cocoa传递到WebView。我特别感兴趣的是3个手指刷回 编辑 似乎即使在我的Macbook Pro上最新的Webkit Nighly上的Sencha Touch厨房水槽中,也没有检测到刷卡事件。然而,对于我来说,有一个更简单的解决方案,在使用Backbone.js历史插件进行部分Ajax风格的页面更新时,可以简单地使用浏览器历史状态(duh,不敢相信我没有想到),这样用户就可以使用浏览器后退按钮或3个手指滑动返回 有一些API可以做到这一点。 例如,这是使用手势API调整大小和旋转的代码:Mac上Webkit中手势的Javascript事件?,javascript,macos,webkit,Javascript,Macos,Webkit,是否可以在Mac桌面上的Webkit上用Javascript获取手势事件,例如3个手指的回扫?我在谷歌上搜索了几次,什么也找不到。否则,我想我可以将它们从Cocoa传递到WebView。我特别感兴趣的是3个手指刷回 编辑 似乎即使在我的Macbook Pro上最新的Webkit Nighly上的Sencha Touch厨房水槽中,也没有检测到刷卡事件。然而,对于我来说,有一个更简单的解决方案,在使用Backbone.js历史插件进行部分Ajax风格的页面更新时,可以简单地使用浏览器历史状态(du
var width = 100, height = 200, rotation = ;
node.ongesturechange = function(e){
var node = e.target;
// scale and rotation are relative values,
// so we wait to change our variables until the gesture ends
node.style.width = (width * e.scale) + "px";
node.style.height = (height * e.scale) + "px";
node.style.webkitTransform = "rotate(" + ((rotation + e.rotation) % 360) + "deg)";
}
node.ongestureend = function(e){
// Update the values for the next time a gesture happens
width *= e.scale;
height *= e.scale;
rotation = (rotation + e.rotation) % 360;
}
您可以阅读本教程:Webkit目前与touch API不兼容 如果您想知道触摸事件api是否受支持,可以使用Modernizer并根据结果修改UI 在这里下载:然后写下如下内容:
if (Modernizr.touch){
// bind to touchstart, touchmove, etc and watch `event.streamId`
} else {
// bind to normal click, mousemove, etc
}
Modernizer还可以自定义body元素的类,这样您就可以使用CSS访问它
您可以使用yepnope js完成它:
当支持这些事件时,您可以使用jQuery mobile。不,我确信它与iPhone API相同。酷炫的多点触摸显示屏。
modernizer.touch
应该能够检测触摸设备(在我们的例子中,iOS设备意味着触摸设备)
yepnope({
test: Modernizr.touch,
yep: 'touch-ui.js',
nope: 'standard-ui.js'
});