Hi,
anybody knows about a good touch-handling/gesture library to manage touch, swipe, pinch etc?
I know about Gestouchx, but it hasn’t been updated in a while (4 years!), so I don’t know if I can really trust it…
I think touch and guestures is already supported by Lime/OpenFl, but haven’t have had experience using those yet.
I’m looking for some gesture library (swipe, pinch, etc.) too, roxlib seems not working with the latest OpenFL for me.
Any updates on that?
I had the same question last December, and ended up rolling my own. I only added swipe support (since that’s all I need). You can see the beginnings of it (GestureManager.hx
) here.
Last I needed swipe support, I also did it myself. I basically checked the start (mouse down) position against the end (mouse up) position. If the absolute vertical change was greater than horizontal, I disregarded it (since I wanted horizontal swiping only). Then I compared the positions, and had a minimum distance required, and some parameters for the amount of time I expected (not too fast, not too slow). Worked pretty well, but a ready-to-use library could be nice
I am building an HTML5 app. I tried Roxlib and it wouldn’t detect multi-touch gestures on that target. I’m happy to say that the HammerJS extern on Haxelib did the trick. You just have to pass the OpenFL stage to it. Works with Away3D.
import hammer.Hammer;
import hammer.Manager;
import hammer.recognizers.Pinch;
import hammer.GestureInteractionData;
import js.Browser;
import js.html.HtmlElement;
///etc. code omitted…
var openflstage:HtmlElement = cast Browser.document.getElementById("content");
// create a manager for that element
pinchManager = new Manager(openflstage);
// create a recognizer
pinch = new Pinch();
// add the recognizer
pinchManager.add(pinch);
pinchManager.on("pinch", onPinch);
private function onPinch (e:GestureInteractionData) {
if(_view.visible == true){
var scale = 1/e.scale;
if ((scale*this._cameraController.distance < 200) && (scale*this._cameraController.distance > 5)){
this._cameraController.distance *= scale;
}
}
}
I’ve made it work ok, however I can’t emulate it on desktop version, for that I see a tough road ahead for debug, any advice on making it work on desktop ? ( Tried touch-emulator.js with no luck).
Any tip would be really appreciated
Best Regards
Luis
What is your tech solution for desktop? Sounds like you have JS support, is it Electron?
Sorry I explain myself bad. I mean to debug in a browser for PC and not mobile!
Sorry for the late reply. I often use Firefox in “Responsive Design Mode” and Apple’s iOS Simulator (paired with Safari for developer tools) for testing.
Hello friend.
I’m trying to test this Hammer library, by flashdevelop.
I’m compiling in html5. I can’t suppress this error:
“Uncaught ReferenceError: Hammer is not defined”
I’ve searched, and I can’t find a solution. I did everything the tutorial shows, but it always shows:
“ReferenceError: Hammer is not defined”.
It looks like it’s not loading the Hammer class, but all the imports are correct:
import hammer.Hammer;
import hammer.Manager;
import hammer.recognizers.*;
import hammer.GestureInteractionData;
import js.Browser;
import js.html.HtmlElement;
Would anyone have an idea?
Tankyou!
In your project.xml did you include a reference to the hammer extern library?
<haxelib name="hammerjs" />
Yes, it’s calling the library.
In the console, the line that gives the error is this:
“var pinchManager = new Hammer.Manager(openflstage);”
The code is:
var openflstage:HtmlElement = cast Browser.document.getElementById(“content”);
// create a manager for that element
var pinchManager:Manager = new Manager(openflstage);
// create a recognizer
var pinch:Pinch = new Pinch();
hammer.js is included and loaded in the HTML code? ReferenceError looks like it wasn’t loaded, so it can’t find Hammer