- Notifications
You must be signed in to change notification settings - Fork 3
Delegates
Delegates provides a mechanism to customize the gesture-recognition behavior based on the application state.
Delegates allow to create coordinated UIs to deliver a better UX.
When a Gesture has assigned a GestureDelegate, the delegate will response to messages to affect the gesture recognition.
Currently, the GestureDelegate instances must override the following methods:
shouldReceiveTouch: function(gesture, view, event) { return true; }
GesturesDelegate can be assigned to Gesture based on the gesture options:
Setting up directly the instance:
var delegate = Em.GestureDelegate.create({ name: 'delegate', isBlocked: false,
shouldReceiveTouch: function(gesture, view, event) { return !this.get('isBlocked'); }}); var view = Em.View.create({ tapOptions: { numberOfRequiredTouches: 1, delegate: delegate }, tapEnd: function(recognizer) { } });
Using delegate name property, after being added to the GestureDelegates instance.
var delegate = Em.GestureDelegate.create({ name: 'application_delegate', isBlocked: false,
shouldReceiveTouch: function(gesture, view, event) { return !this.get('isBlocked'); }}); Em.GestureDelegates.add(delegate);
var view = Em.View.create({
tapOptions: { numberOfRequiredTouches: 1, delegateName: 'application_delegate' },
tapEnd: function(recognizer) { }
});