FACEBOOK STYLE SLIDE OUT MENU IN JQUERY MOBILE

FACEBOOK STYLE SLIDE OUT MENU IN JQUERY MOBILE

FACEBOOK STYLE SLIDE OUT MENU IN JQUERY MOBILE_第1张图片

I wanted to recreate the slide out menu in the Facebook iPhone app. I also wanted implement it in a jQuery mobile layout. This is what I came up with.

 

HTML



	
	FB Style Menu
	
	
	
	
	
	
	
	
 



Menu

FB Style Menu

Note: You can swipe right/left to show/close menu.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

jQuery

$(function(){
	var menuStatus;

	$("a.showMenu").click(function(){
		if(menuStatus != true){
		$(".ui-page-active").animate({
			marginLeft: "165px",
		  }, 300, function(){menuStatus = true});
		  return false;
		  } else {
			$(".ui-page-active").animate({
			marginLeft: "0px",
		  }, 300, function(){menuStatus = false});
			return false;
		  }
	});

	$('.pages').live("swipeleft", function(){
		if (menuStatus){
		$(".ui-page-active").animate({
			marginLeft: "0px",
		  }, 300, function(){menuStatus = false});
		  }
	});

	$('.pages').live("swiperight", function(){
		if (!menuStatus){
		$(".ui-page-active").animate({
			marginLeft: "165px",
		  }, 300, function(){menuStatus = true});
		  }
	});

	$("#menu li a").click(function(){
		var p = $(this).parent();
		if($(p).hasClass('active')){
			$("#menu li").removeClass('active');
		} else {
			$("#menu li").removeClass('active');
			$(p).addClass('active');
		}
	});

});

Demo Download from GitHub

你可能感兴趣的:(FACEBOOK STYLE SLIDE OUT MENU IN JQUERY MOBILE)