// open containerWindow
$.containerWindow.open();
// Listen for android back button and close all Views on top that might be displayed
$.containerWindow.addEventListener('android:back', closeNavigationView);
// add app EventListener to openCloseMenu
Ti.App.addEventListener('app:openCloseMenu', function(e) {
openDrawer();
});
// START FUNCTION - handleSwipe
function handelSwipe(e){
Ti.API.log(e);
var direction = e.direction;
if (direction == "right"){
if (Alloy.Globals.drawerOpen){
openDrawer();
};
};
};
// END FUNCTION - handleSwipe
// START FUNCTION - openDrawer
function openDrawer(){
// START IF - Alloy.Globals.drawerOpen true close else open
if (Alloy.Globals.drawerOpen){
moveTo="0";
Alloy.Globals.drawerOpen = false;
// fire app:closeMenuFunction
Ti.App.fireEvent('app:closeMenuFunction');
$.containerWindow.removeEventListener('swipe', function(e){
handelSwipe(e);
});
}else{
moveTo="250dp";
Alloy.Globals.drawerOpen = true;
$.containerWindow.addEventListener('swipe', function(e){
handelSwipe(e);
});
};
// END IF - Alloy.Globals.drawerOpen true close else open
// set mainView Width
$.mainView.width=Ti.Platform.displayCaps.platformWidth;
// animate mainView
$.mainView.animate({
right:moveTo,
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT,
duration:200
});
};
// END FUNCTION - openDrawer
Ti.Gesture.addEventListener('orientationchange', function(e) {
$.mainView.width=Ti.Platform.displayCaps.platformWidth;
});
Titanium Alloy Nice Swipe Menu Functions
