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

Drag Geture #77

Open
wztechno opened this issue Nov 26, 2014 · 5 comments
Open

Drag Geture #77

wztechno opened this issue Nov 26, 2014 · 5 comments

Comments

@wztechno
Copy link

Hello and Thank you for this great project.

I have strugling to add drag gesture to an image in starling or feathers but with no luck.

I tried to use
DragGesture.add(myImage, {minTouchPointsCount: 1, maxTouchPointsCount: 3});

But I could not import its class as it was not found.. Can you kindly help? I need to zoom in an image and be able to see the image around?

Thank you in advance

@fljot
Copy link
Owner

fljot commented Nov 26, 2014

Yeah, that's like 3 years old syntax) project has become better since then. Check out readme and examples (slightly outdated, but you can get the idea. Also it's Flex there for examples, but it doesn't changes anything.) https://github.com/fljot/GestouchExamples/tree/master/src/org/gestouch/examples/views

@wztechno
Copy link
Author

Thank you for your reply.

I went over the examples and tried them, but unfortunately, I could not find something specific for dragging. Do you mean that we can use tap gesture events of GESTURE_BEGAN GESTURE_CHANGED and GESTURE_ENDED to make use of drag ?

@wztechno
Copy link
Author

For anyone interested, this worked for me

        var drag:LongPressGesture = new LongPressGesture(imgLoader);
        drag.minPressDuration = 100;
        drag.addEventListener(org.gestouch.events.GestureEvent.GESTURE_BEGAN, onDragBeginning);
        drag.addEventListener(org.gestouch.events.GestureEvent.GESTURE_CHANGED, onDragChanged);
        drag.addEventListener(org.gestouch.events.GestureEvent.GESTURE_ENDED, onDragEnded);

@wztechno
Copy link
Author

and here is the Full Code

        var drag:LongPressGesture = new LongPressGesture(imgLoader);
        var dragInitialPoint:Point = new Point();
        drag.minPressDuration = 1;
        drag.addEventListener(org.gestouch.events.GestureEvent.GESTURE_BEGAN, onDragBeginning);
        drag.addEventListener(org.gestouch.events.GestureEvent.GESTURE_CHANGED, onDragChanged);
        drag.addEventListener(org.gestouch.events.GestureEvent.GESTURE_ENDED, onDragEnded);

function onDragBeginning(event:Event):void
{
const gesture:LongPressGesture = event.target as LongPressGesture;
dragInitialPoint = gesture.location;
}

        function onDragEnded(event:Event):void
        {
        //  trace("Drag Ended");

        }

        function onDragChanged(event:Event):void
        {
            const gesture:LongPressGesture = event.target as LongPressGesture;

            var matrix:Matrix = imgLoader.transformationMatrix;
            matrix.translate(gesture.location.x - dragInitialPoint.x, gesture.location.y - dragInitialPoint.y);
            imgLoader.transformationMatrix = matrix;
            dragInitialPoint = gesture.location;

        }       

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