Skip to content
Browse files

Add a custom tap event inside main panel to detects tapped events onl…

…y when slider menu is open.
  • Loading branch information...
1 parent a2aa4b7 commit 0f2d58465a670c29e759d8d0d0d6c22e8f166498 Xevi committed Mar 20, 2012
Showing with 27 additions and 2 deletions.
  1. +12 −1 slider_menu/controller/SliderMenuController.js
  2. +15 −1 slider_menu/view/Main.js
View
13 slider_menu/controller/SliderMenuController.js
@@ -39,12 +39,23 @@ Ext.define('SliderMenu.controller.SliderMenuController', {
push: 'onMainPush',
pop: 'onMainPop',
tap: 'onMainTapped',
+ },
+
+ mainWrapper: {
+ tap: 'onMainTapped'
}
},
},
+ /**
+ * When the main menu is tapped (only when it's masked -> menu is open)
+ * we close slider menu
+ */
onMainTapped: function(){
- console.log('Main tapped');
+ var main = this.getMain();
+ var menu = this.getMenu();
+
+ main.closeMenu(menu.getCloseAnimDuration());
},
/**
View
16 slider_menu/view/Main.js
@@ -146,7 +146,21 @@ Ext.define('SliderMenu.view.Main', {
constraint.min.x = offsetX;
constraint.max.x = offsetX;
this.slideMenu(offsetX, duration);
- this.setMasked(masked);
+
+ if(masked){
+ //open menu -> create a special mask to detects tap events
+ this.setMasked({
+ xtype: 'mask',
+ listeners: {
+ tap: function(){
+ //Main (this.parent) fires a tap event only when the main is wrapped
+ this.parent.fireEvent('tap');
+ }
+ }
+ })
+ }else{
+ this.setMasked(false);
+ }
},
/**

0 comments on commit 0f2d584

Please sign in to comment.
Something went wrong with that request. Please try again.