Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZoomGesture: infinity scaleX/scaleY when touching and clicking #76

Open
rdoi opened this issue Oct 22, 2014 · 3 comments
Open

ZoomGesture: infinity scaleX/scaleY when touching and clicking #76

rdoi opened this issue Oct 22, 2014 · 3 comments

Comments

@rdoi
Copy link

rdoi commented Oct 22, 2014

This is a very specific situation when using a device that have both mouse and touch capabilities (Win8).

If you click down with the mouse (keep pressed) and then touch and pan around with the finger somewhere else, a ZoomGesture is detected with a serie of scaleX and scaleY with 0 and "Infinity" values.

Not sure what should be the best behavior in this case, but I think "Infinity" value should not happen.

Here is a quick code:

package {
    import org.gestouch.core.Gestouch;
    import org.gestouch.events.GestureEvent;
    import org.gestouch.gestures.ZoomGesture;
    import org.gestouch.input.NativeInputAdapter;

    import flash.display.Sprite;
    import flash.events.Event;

    public class ZoomTester extends Sprite {
        private var zoomGesture : ZoomGesture ;

        public function ZoomTester() {
            addEventListener(Event.ADDED_TO_STAGE, onStage);    
        }

        private function onStage(event : Event) : void {
            Gestouch.inputAdapter = new NativeInputAdapter(this.stage, true, true);

            const s:Sprite= new Sprite();
            s.graphics.beginFill(0x00ffff);
            s.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
            addChild(s);

            zoomGesture= new ZoomGesture(this);
            zoomGesture.addEventListener(GestureEvent.GESTURE_CHANGED, onZoom);
        }

        private function onZoom(event : GestureEvent) : void {
            trace("Zoom:", zoomGesture.scaleX, zoomGesture.scaleY);
        }

    }
}
@fljot
Copy link
Owner

fljot commented Oct 23, 2014

@rdoi totally shouldn't.

I've added some logging (check out recent commits in develop). You can compile against source code (but you will need to add conditional compilation flag CONFIG::GestouchDebug true) or build debug swc first:
Maven:
mvn clean package -Dprofile=debug

or Ant:
ant compile.swc.debug

check out the logs and we'll see what kind of problem between touch and mouse events you have.

@rdoi
Copy link
Author

rdoi commented Oct 24, 2014

Well, I am not sure if I've expressed myself correctly.

There is a problem in the zoom gesture recognition when a mouse and touch happens at same time, in which the reported scale (offset) returns an "Infinity" value.

Its probably because the OS (Windows) "moves" the mouse cursor to where a touch happens. Its true also when you are still pressing down the mouse button, and touch the screen somewhere else.

So, when the 2nd real touch is recognized, the first touch (the mousedown) position is reported in the same place than the 2nd touch.

And if you try to calculate the distance between these 2 points you get a 0, hence returning a "Infinity" if you use it as divisor.

ZoomGesture.onTouchMove: around #117

   if (lockAspectRatio)
            {
                _scaleX *= currTransformVector.length / _transformVector.length; // <-- HERE
                _scaleY = _scaleX;
            }
 // (...)

@fljot
Copy link
Owner

fljot commented Oct 24, 2014

@rdoi yeah, I understood you. But as we didn't have any real information about how OS delivers input information to the Flash runtime, I added logging. With it we can see exactly what is the input (events, ids and positions). No point to speculate, just try it =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants