Javascript events for gestures in Webkit on Mac?

Is it possible to receive gesture events, for example, swipe 3 fingers backwards on Webkit on the Mac desktop in Javascript? I did a few google searches and didn't find anything. Otherwise, I think I could pass them from Cocoa to WebView. I am particularly interested in 3 fingers moving backwards.

EDIT

It seems that even in the Sencha Touch Kitchen Sink application on the latest Webkit nightly updates on my Macbook Pro, no scroll events were detected, However, for me there is a simple solution to just use the state of the browser history when partially updating Ajax style pages (I think I can’t believe that I did not think about it) with the Backbone.js history plugin so that the user can go back using the browser button, or 3 fingers.

+4
source share
2 answers

Webkit is currently not compatible with the touch API.

If you want to know if apt events support api, you can use modernizr and change your interface depending on the results ...

Download it here: http://www.modernizr.com/ Then write something like this:

if (Modernizr.touch){ // bind to touchstart, touchmove, etc and watch `event.streamId` } else { // bind to normal click, mousemove, etc } 

Modernizr also customize your body element class so you can access it using CSS

You can execute it with yepnope js: http://yepnopejs.com/

 yepnope({ test: Modernizr.touch, yep: 'touch-ui.js', nope: 'standard-ui.js' }); 

And when events are supported, you can use jQuery mobile.

+2
source

There are APIs for this. As an example, this is the code for resizing and rotating using API gestures:

 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; } 

You can read this tutorial: Touching and Gesturing on iPhone

+1
source

Source: https://habr.com/ru/post/1336422/


All Articles