@@ -109,6 +109,8 @@ export function setPropertyValue(instance: view.View, instanceModule: Object, ex
109109 if ( isBinding ( propertyValue ) && instance . bind ) {
110110 if ( isEvent ) {
111111 attachEventBinding ( instance , propertyName , propertyValue ) ;
112+ } else if ( isGesture ( propertyName , instance ) ) {
113+ attachGestureBinding ( instance , propertyName , propertyValue ) ;
112114 } else {
113115 var bindOptions = bindingBuilder . getBindingOptions ( propertyName , getBindingExpressionFromAttribute ( propertyValue ) ) ;
114116 instance . bind ( {
@@ -185,6 +187,22 @@ function attachEventBinding(instance: view.View, eventName: string, value: strin
185187 instance . on ( observable . Observable . propertyChangeEvent , propertyChangeHandler ) ;
186188}
187189
190+ function attachGestureBinding ( instance : view . View , gestureName : string , value : string ) {
191+ // Get the event handler from instance.bindingContext.
192+ var propertyChangeHandler = ( args : observable . PropertyChangeData ) => {
193+ if ( args . propertyName === "bindingContext" ) {
194+ var handler = instance . bindingContext && instance . bindingContext [ getBindingExpressionFromAttribute ( value ) ] ;
195+ // Check if the handler is function and add it to the instance for specified event name.
196+ if ( types . isFunction ( handler ) ) {
197+ instance . observe ( gestures . fromString ( gestureName . toLowerCase ( ) ) , handler ) ;
198+ }
199+ instance . off ( observable . Observable . propertyChangeEvent , propertyChangeHandler ) ;
200+ }
201+ } ;
202+
203+ instance . on ( observable . Observable . propertyChangeEvent , propertyChangeHandler ) ;
204+ }
205+
188206function isGesture ( name : string , instance : any ) : boolean {
189207 return gestures . fromString ( name . toLowerCase ( ) ) !== undefined ;
190208}
0 commit comments