66 GestureTouchEventData ,
77 HandlerType ,
88 Manager ,
9+ NativeViewGestureHandler ,
910 PanGestureHandler ,
1011 TapGestureHandler ,
1112 install as installGestures ,
@@ -16,7 +17,6 @@ installGestures(false);
1617const OPEN_DURATION = 200 ;
1718const CLOSE_DURATION = 200 ;
1819export const PAN_GESTURE_TAG = 12431 ;
19- export const TAP_GESTURE_TAG = 12421 ;
2020const DEFAULT_TRIGGER_WIDTH = 20 ;
2121const SWIPE_DISTANCE_MINIMUM = 10 ;
2222
@@ -92,8 +92,6 @@ export class Drawer extends GridLayout {
9292 leftOpenedDrawerAllowDraging = true ;
9393 rightOpenedDrawerAllowDraging = true ;
9494 panGestureHandler : PanGestureHandler ;
95- tapGestureHandler : TapGestureHandler ;
96- // nativeGestureHandler: PanGestureHandler;
9795 showingSide : Side = null ;
9896 needToSetSide : Side ;
9997
@@ -117,29 +115,20 @@ export class Drawer extends GridLayout {
117115
118116 this . insertChild ( this . backDrop , 0 ) ;
119117 }
118+ onBackdropTap ( ) {
119+ this . close ( ) ;
120+ }
120121 initGestures ( ) {
121122 const manager = Manager . getInstance ( ) ;
122123 const gestureHandler = manager . createGestureHandler ( HandlerType . PAN , PAN_GESTURE_TAG , {
123124 shouldStartGesture : this . shouldStartGesture . bind ( this ) ,
124- // waitFor: [NATIVE_GESTURE_TAG],
125- // disallowInterruption: true,
126- // simultaneousHandlers: [NATIVE_GESTURE_TAG],
127- // shouldCancelWhenOutside: true,
128- // activeOffsetX: this.leftSwipeDistance,
129125 minDist : SWIPE_DISTANCE_MINIMUM ,
130- // failOffsetX: SWIPE_DISTANCE_MINIMUM,
131126 } ) ;
132127 gestureHandler . on ( GestureHandlerTouchEvent , this . onGestureTouch , this ) ;
133128 gestureHandler . on ( GestureHandlerStateEvent , this . onGestureState , this ) ;
134129 gestureHandler . attachToView ( this ) ;
135130 this . panGestureHandler = gestureHandler as any ;
136131
137- this . tapGestureHandler = manager . createGestureHandler ( HandlerType . TAP , TAP_GESTURE_TAG , { } ) ;
138- this . tapGestureHandler . on ( GestureHandlerStateEvent , this . onTapGestureState , this ) ;
139- this . tapGestureHandler . attachToView ( this . backDrop ) ;
140- // if (this.mainContent) {
141- // this.initNativeGestureHandler(this.mainContent);
142- // }
143132 }
144133 shouldStartGesture ( data ) {
145134 const width = this . measureWidth ;
@@ -156,10 +145,21 @@ export class Drawer extends GridLayout {
156145 }
157146 initNativeView ( ) {
158147 super . initNativeView ( ) ;
148+ this . backDrop . on ( 'tap' , this . onBackdropTap , this ) ;
159149 if ( this . gestureEnabled ) {
160150 this . initGestures ( ) ;
161151 }
162152 }
153+ disposeNativeView ( ) {
154+ super . disposeNativeView ( ) ;
155+ this . backDrop . off ( 'tap' , this . onBackdropTap , this ) ;
156+ if ( this . panGestureHandler ) {
157+ this . panGestureHandler . off ( GestureHandlerTouchEvent , this . onGestureTouch , this ) ;
158+ this . panGestureHandler . off ( GestureHandlerStateEvent , this . onGestureState , this ) ;
159+ this . panGestureHandler . detachFromView ( ) ;
160+ this . panGestureHandler = null ;
161+ }
162+ }
163163 [ gestureEnabledProperty . setNative ] ( value ) {
164164 if ( this . panGestureHandler ) {
165165 this . panGestureHandler . enabled = value ;
@@ -180,26 +180,9 @@ export class Drawer extends GridLayout {
180180 this . modes [ 'right' ] = value ;
181181 this . onSideModeChanged ( 'right' , value , oldValue ) ;
182182 }
183- disposeNativeView ( ) {
184- super . disposeNativeView ( ) ;
185- if ( this . panGestureHandler ) {
186- this . panGestureHandler . off ( GestureHandlerTouchEvent , this . onGestureTouch , this ) ;
187- this . panGestureHandler . off ( GestureHandlerStateEvent , this . onGestureState , this ) ;
188- this . panGestureHandler . detachFromView ( ) ;
189- this . panGestureHandler = null ;
190- }
191- if ( this . tapGestureHandler ) {
192- this . tapGestureHandler . off ( GestureHandlerStateEvent , this . onTapGestureState , this ) ;
193- this . tapGestureHandler . detachFromView ( ) ;
194- this . tapGestureHandler = null ;
195- }
196- }
197183 public _onMainContentChanged ( oldValue : View , newValue : View ) {
198184 // console.log('_onMainContentChanged', oldValue, newValue);
199185 if ( oldValue ) {
200- // if (this.nativeGestureHandler) {
201- // this.nativeGestureHandler.detachFromView(oldValue);
202- // }
203186 this . removeChild ( oldValue ) ;
204187 }
205188
@@ -360,6 +343,7 @@ export class Drawer extends GridLayout {
360343 args . object . cancel ( ) ;
361344 return ;
362345 }
346+ // this.nativeGestureHandler.cancel();
363347 }
364348 if ( state === GestureState . ACTIVE ) {
365349 const width = this . getMeasuredWidth ( ) ;
@@ -482,9 +466,9 @@ export class Drawer extends GridLayout {
482466 if ( position !== 0 ) {
483467 this . showingSide = side ;
484468 ( side === 'right' ? this . rightDrawer : this . leftDrawer ) . visibility = 'visible' ;
485- if ( trData . backDrop && trData . backDrop . opacity > 0 ) {
469+ if ( trData . backDrop && trData . backDrop . opacity > 0 && this . backDrop . visibility !== 'visible' ) {
486470 this . backDrop . opacity = 0 ;
487- this . backDrop . visibility = trData . backDrop && trData . backDrop . opacity > 0 ? 'visible' : 'hidden ';
471+ this . backDrop . visibility = 'visible' ;
488472 }
489473 this . notify ( { eventName : 'open' , side, duration } as DrawerEventData ) ;
490474 } else {
0 commit comments