Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0Digg thisPin on Pinterest0Email this to someone
// 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;

});
If you enjoyed this post, why not leave a comment or consider a Donation as a token of your appreciation. If you need help implementing something you saw on this site or any other project why not Hire Me?
Titanium Alloy Nice Swipe Menu Functions
Tagged on:                 

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading Facebook Comments ...