Gesture/touch library

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…

Maybe you can try this one : https://github.com/rockswang/roxlib

1 Like

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.

1 Like

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

2 Likes

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