-
Notifications
You must be signed in to change notification settings - Fork 478
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
Gesture support using Hammer.js #244
Conversation
Ho Shit @jchavarri I totally missed this. This is awesome! |
Thanks! :) Do you think this is the right approach to add other gestures to Framer? If yes, I would keep adding the remaining stuff on the todo list in order to finish this PR. |
Yeah this looks really good. I'd love to finish this up and add it. |
👍 I'll keep working on this branch and ping you in this thread once it's "ready for review". |
Awesome! |
@koenbok So I think this is ready for review! I didn't add any testing to it as I don't have any clue on how to test this kind of gestural interaction 😅. I saw that the HammerJS guys have created a "Simulator". Maybe we could add something like this to test it? In order to test all the available gestures and events, I have created a Framer project. You can test it here, the code for this demo is on Github. So the next things I'm interested in adding are:
Let me know your thoughts! :) |
Hey @jchavarri I'm going to land a big one first: https://github.com/koenbok/Framer/tree/context-freeze-restore. This will refactor a bunch of event and context stuff. The main reason is that all the event/dom handling became a huge mess, and I wanted to clean up the context api. I think the implications for this pr are mostly renames (for example EventManager vs DOMEventManager). |
👏🏻
|
Ok, cool! I'll keep an eye on the |
Hey @jchavarri I'm ready with https://github.com/koenbok/Framer/tree/context-freeze-restore. Wanna give it a try? |
Sure @koenbok, I will be more than happy to wrap this up! I think I can have something by tomorrow. Side note: regarding the tests, I saw the HammerJS team uses both manual and unit tests:
Do you think adding any of these kinds of tests to this PR is worth it? |
@jchavarri You're and utter legend. I can't wait for this to drop. |
…gic to DOMEventManager.coffee. # Conflicts: # framer/EventManager.coffee # package.json
@jornvandijk Sorry, but I have to disagree :) you and @koenbok are the original rockstars that started all this top-notch-designed hyper-elegantly-coded prototyping madness! 😊 I am also eager to see what you and the awesome Framer community do with these new events... So, everything has been merged and integrated with branch
I still have pending the addition of the HammerJS Simulator class -or something similar- in order to add more tests for the gesture events. Let me know your thoughts! |
Thanks for the kind words! Yeah, this is gonna be a substantial update to our docs. Will take some time to write it all out in an easy/understandable way. |
Conflicts: package.json
Merged with master. Updated to add gesture event helpers (see PR #272 ) |
SliderComponent Update
…chavarri-gestures # Conflicts: # framer/DOMEventManager.coffee # test/tests/LayerTest.coffee
Hmpf, I can't update the branch :-/ @jchavarri could you give me write access to your Framer repo? I think that is the only way to keep the PR intact. |
It would also be great to have some Framer Studio projects with examples of common stuff. |
@koenbok Access granted! :) Related to the examples, can they be the same examples included in the framer-gestures.framer repo I set up? Or maybe they should be splitted into a separate .framer project each? If they need to be splitted into separate projects, it won't take long as each example is already in a separate file/module. This is a capture of the main screen that points to the examples I created in that repo: |
Woop yeah that's prefect. |
Gesture support using Hammer.js
Beng! |
🚀 |
This is awesome, and I was really hoping this would happen someday! |
That's a very good point. These are my thoughts on both observations: 1. Consistency I think these are all the event types that can be passed to a listener on Framer atm:
Hammer already takes care of these differences between
Apparently there's a NOTE: I'm afraid there will always be events like 2. LayerDraggable This one is simpler to tackle :) I think that just by replacing |
Ongoing work to be discussed, don't merge! :)
Related to issue #107. Before I keep working on it, I would like to know your thoughts.
Here's a first attempt to integrate Hammer with Framer, so we can recognize pinches, rotations, panning, etc. From the few tests I've done it seems to work well together with the existing events. I have tried to make both gesture and browser events transparent for the final user, even if behind the scenes they are two completely different things.
I see this as an exercise to explore how gesture events could be handled in Framer. I went with Hammer because they already deal with a lot of corner cases and gives a good idea on how to solve the gesture recognition in an elegant way. But maybe in the future this dependency could be removed by implementing the functionality in Framer?
This is an overview on how Hammer implements classes / concepts:
Input
: everything that can be consider a source of a gestural event. Subclasses: MouseInput, TouchInput, PointerEventInput, etc. This is also the class calculating velocities, directions and every extra info of the events.Recognizer
: The gestures themselves. Subclasses: PanRecognizer, PinchRecognizer, etc. The base class contains a state machine to follow the gesture evolution.Manager
: Assign handlers (or listeners) to recognizers based on a specific device input. It has similar responsibilities as Framer'sEventManagerElement
.So what I've done for now is adding a GestureManager class that wraps Hammer functionality, and creates recognizers as they are requested depending on the gestures the layer is listening to.
Still to do:
removeEventListener
: this one is a bit tricky: after removing a listener, we should remove the given gesture recognizer if there are no more events remaining of that type attached to the layer.Side note: if this PR finally see the light, it would be very nice to integrate this Touch Emulator into Framer Studio, so users could emulate multi touch gestures using their keyboard. That would bring Framer a step closer to the iPhone Simulator!! :)
Finally, a small example that you can copy & paste: