<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codrops &#187; rotating</title>
	<atom:link href="http://tympanus.net/codrops/tag/rotating/feed/" rel="self" type="application/rss+xml" />
	<link>http://tympanus.net/codrops</link>
	<description>Useful resources and inspiration for creative minds</description>
	<lastBuildDate>Mon, 06 Feb 2012 07:30:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rotating Image Slider with jQuery</title>
		<link>http://tympanus.net/codrops/2011/04/28/rotating-image-slider/</link>
		<comments>http://tympanus.net/codrops/2011/04/28/rotating-image-slider/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 15:32:06 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[rotating]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=4701</guid>
		<description><![CDATA[View demo Download source In the following tutorial we will create an asymmetrical image slider with a little twist: when sliding the pictures we will slightly rotate them and delay the sliding of each element. The unusual shape of the slider is created by some elements placement and the use of thick borders. We will [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://tympanus.net/Tutorials/RotatingImageSlider/"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/04/RotatingImageSlider.jpg" alt="" title="RotatingImageSlider" width="580" height="315" class="aligncenter size-full wp-image-4704" /></a><br />
<a class="demo" href="http://tympanus.net/Tutorials/RotatingImageSlider/" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/RotatingImageSlider/RotatingImageSlider.zip">Download source</a></p>
<p>In the following tutorial we will create an asymmetrical image slider with a little twist: when sliding the pictures we will slightly rotate them and delay the sliding of each element. The unusual shape of the slider is created by some elements placement and the use of thick borders. We will also add an autoplay option and the mousewheel functionality.</p>
<p>We&#8217;ll use the <a target="_blank" href="https://github.com/heygrady/transform/wiki">jQuery 2D Transformation Plugin</a> for rotating the images and the <a target="_blank" href="https://github.com/brandonaaron/jquery-mousewheel">jQuery Mousewheel Plugin</a> by Brandon Aaron for the mousewheel control.</p>
<p>The beautiful photos are by Andrew and Lili and you can see their Behance profile here:<br />
<a target="_blank" href="http://www.behance.net/AndrewLili">http://www.behance.net/AndrewLili</a><br />
The images are licensed under the <a target="_blank" href="http://creativecommons.org/licenses/by-nc/3.0/">Creative Commons Attribution-NonCommercial 3.0 Unported License</a>.</p>
<p>Allrighty! Let&#8217;s start with the HTML!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>First, we will wrap all our slider elements in a wrapper with the class &#8220;rm_wrapper&#8221;:</p>
<pre class="brush:xml">
&lt;div class="rm_wrapper"&gt;
...
&lt;/div&gt;
</pre>
<p>Inside of that wrapper we will have a container for the actual slider list, some mask and corner elements, the heading and a hidden div that will contain all the image sets:</p>
<pre class="brush:xml">
&lt;div id="rm_container" class="rm_container"&gt;
	&lt;ul&gt;
		&lt;li data-images="rm_container_1" data-rotation="-15"&gt;
			&lt;img src="images/1.jpg"/&gt;
		&lt;/li&gt;
		&lt;li data-images="rm_container_2" data-rotation="-5"&gt;
			&lt;img src="images/2.jpg"/&gt;
		&lt;/li&gt;
		&lt;li data-images="rm_container_3" data-rotation="5"&gt;
			&lt;img src="images/3.jpg"/&gt;
		&lt;/li&gt;
		&lt;li data-images="rm_container_4" data-rotation="15"&gt;
			&lt;img src="images/4.jpg"/&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;div id="rm_mask_left" class="rm_mask_left"&gt;&lt;/div&gt;
	&lt;div id="rm_mask_right" class="rm_mask_right"&gt;&lt;/div&gt;
	&lt;div id="rm_corner_left" class="rm_corner_left"&gt;&lt;/div&gt;
	&lt;div id="rm_corner_right" class="rm_corner_right"&gt;&lt;/div&gt;
	&lt;h2&gt;Fashion Explosion 2012&lt;/h2&gt;
	&lt;div style="display:none;"&gt;
		&lt;div id="rm_container_1"&gt;
			&lt;img src="images/1.jpg"/&gt;
			&lt;img src="images/5.jpg"/&gt;
			&lt;img src="images/6.jpg"/&gt;
			&lt;img src="images/7.jpg"/&gt;
		&lt;/div&gt;
		&lt;div id="rm_container_2"&gt;
			&lt;img src="images/2.jpg"/&gt;
			&lt;img src="images/8.jpg"/&gt;
			&lt;img src="images/9.jpg"/&gt;
			&lt;img src="images/10.jpg"/&gt;
		&lt;/div&gt;
		&lt;div id="rm_container_3"&gt;
			&lt;img src="images/3.jpg"/&gt;
			&lt;img src="images/11.jpg"/&gt;
			&lt;img src="images/12.jpg"/&gt;
			&lt;img src="images/13.jpg"/&gt;
		&lt;/div&gt;
		&lt;div id="rm_container_4"&gt;
			&lt;img src="images/4.jpg"/&gt;
			&lt;img src="images/14.jpg"/&gt;
			&lt;img src="images/15.jpg"/&gt;
			&lt;img src="images/16.jpg"/&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>So the unordered lists will have the first set of four images where each list element has some data attributes for the image sets and the rotation degree. We will use that data to know which images come next and how much each image should be rotated.</p>
<p>The mask and corner divs will be absolute elements that we will place on top of the slider, slightly rotated in order to cover some areas. Since we will use the same background color for these elements like the body&#8217;s background color, we will create the illusion of the images being shaped in a certain way.</p>
<p>Then we&#8217;ll add the elements for the navigation and the autoplay controls:</p>
<pre class="brush:xml">
&lt;div class="rm_nav"&gt;
	&lt;a id="rm_next" href="#" class="rm_next"&gt;&lt;/a&gt;
	&lt;a id="rm_prev" href="#" class="rm_prev"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div class="rm_controls"&gt;
	&lt;a id="rm_play" href="#" class="rm_play"&gt;Play&lt;/a&gt;
	&lt;a id="rm_pause" href="#" class="rm_pause"&gt;Pause&lt;/a&gt;
&lt;/div&gt;
</pre>
<p>Let&#8217;s take a look at the CSS.</p>
<h3>The CSS</h3>
<p>First, we&#8217;ll reset some styles and define the properties for the body. (Remember, if we would have another background color, we would want to change the background and border colors of some of the elements in our slider, too.)</p>
<pre class="brush:css">
@import url('reset.css');
body{
	background:#f0f0f0;
	color:#000;
	font-family: 'PT Sans Narrow', Arial, sans-serif;
	font-size:16px;
}
a{
	color:#000;
	text-decoration:none;
}
h1{
	padding:10px;
	margin:20px;
	font-size:40px;
	text-transform:uppercase;
	text-shadow:0px 0px 1px #fff;
	color:#333;
	background:transparent url(../images/line.png) repeat-x bottom left;
}
</pre>
<p>The main wrapper will have the following style:</p>
<pre class="brush:css">
.rm_wrapper{
	width:1160px;
	margin:0 auto;
	position:relative;
}
</pre>
<p>The container for the slider will have any overflow hidden, which will help shaping our slider since we will cut off the outer sides of it:</p>
<pre class="brush:css">
.rm_container{
	width:1050px;
	overflow:hidden;
	position:relative;
	height:530px;
	margin:0 auto;
}
</pre>
<p>The heading will have the following style:</p>
<pre class="brush:css">
.rm_container h2{
	background:transparent url(../images/lines.png) repeat top left;
	padding:10px 30px;
	position:absolute;
	bottom:170px;
	right:0px;
	color:#000;
	font-size:36px;
	text-transform:uppercase;
	text-shadow:1px 0px 1px #fff;
}
</pre>
<p>Let&#8217;s define the width for the ul to be bigger than the container since we want to make the list element float next to each other:</p>
<pre class="brush:css">
.rm_container ul{
	width:1170px;
}
</pre>
<p>By giving a negative left margin and a thick border to the list element, we will overlap the images and cut off the right sides so that we create our asymmetrical shapes by rotating the elements then. The border color will be the same like the background color of the body (or the container). </p>
<pre class="brush:css">
.rm_container ul li{
	float:left;
	margin-left:-80px;
	position:relative;
	overflow:hidden;
	width:310px;
	height:465px;
	border:30px solid #f0f0f0;
	border-width:50px 30px 0px 30px;
	background-color:#f0f0f0;
}
</pre>
<p>We&#8217;ll position the images absolutely:</p>
<pre class="brush:css">
.rm_container ul li img{
	position:absolute;
	top:0px;
	left:0px;
}
</pre>
<p>In the following we will style the mask and the corner elements. They will be all positioned absolutely and we&#8217;ll give them the grey background color. By rotating them, we&#8217;ll make the images to appear as being &#8220;shaped&#8221;:</p>
<pre class="brush:css">
.rm_mask_right, .rm_mask_left{
	position: absolute;
	height: 110px;
	background: #f0f0f0;
	width: 530px;
	bottom: -30px;
	left: 0px;
	-moz-transform:rotate(-3deg);
	-webkit-transform:rotate(-3deg);
	transform:rotate(-3deg);
}
.rm_mask_right{
	left:auto;
	right:0px;
	-moz-transform:rotate(3deg);
	-webkit-transform:rotate(3deg);
	transform:rotate(3deg);
}
.rm_corner_right, .rm_corner_left{
	background: #f0f0f0;
	position:absolute;
	width:200px;
	height:100px;
	bottom:0px;
	left:-65px;
	-moz-transform:rotate(45deg);
	-webkit-transform:rotate(45deg);
	transform:rotate(45deg);
}
.rm_corner_right{
	left:auto;
	right:-65px;
	-moz-transform:rotate(-45deg);
	-webkit-transform:rotate(-45deg);
	transform:rotate(-45deg);
}
</pre>
<p>The navigation elements will be placed to the left and right of the main container:</p>
<pre class="brush:css">
.rm_nav a{
	position:absolute;
	top:200px;
	width:38px;
	height:87px;
	cursor:pointer;
	opacity:0.7;
}
.rm_nav a:hover{
	opacity:1.0;
}
.rm_nav a.rm_next{
	background:transparent url(../images/next.png) no-repeat top left;
	right:0px;
}
.rm_nav a.rm_prev{
	background:transparent url(../images/prev.png) no-repeat top left;
	left:0px;
}
</pre>
<p>The pause/play control will be placed to the top left of the main container:</p>
<pre class="brush:css">
.rm_controls{
	position:absolute;
	top:0px;
	left:-40px;
	height:20px;
}
.rm_controls a{
	cursor:pointer;
	opacity:0.7;
	padding-left:24px;
	font-size:16px;
	text-transform:uppercase;
	height:20px;
	float:left;
	line-height:20px;
}
.rm_controls a:hover{
	opacity:1.0;
}
.rm_controls a.rm_play{
	display:none;
	background:transparent url(../images/play.png) no-repeat center left;
}
.rm_controls a.rm_pause{
	background:transparent url(../images/pause.png) no-repeat center left;
}
</pre>
<p>And that&#8217;s all the style! Let add the spice!</p>
<h3>The JavaScript</h3>
<p>The main idea for the slider functionality is to add another image before the current one with a slightly increased rotation degree than the current item. Then we will animate the rotation and make the new images appear.<br />
So let&#8217;s start by caching some elements and checking if we are dealing with a special needs browser in order to deal with some issues:</p>
<pre class="brush:js">
//our 4 items
var $listItems 		= $('#rm_container &gt; ul &gt; li'),
	totalItems		= $listItems.length,

	//the controls
	$rm_next		= $('#rm_next'),
	$rm_prev		= $('#rm_prev'),
	$rm_play		= $('#rm_play'),
	$rm_pause		= $('#rm_pause'),

	//the masks and corners of the slider
	$rm_mask_left	= $('#rm_mask_left'),
	$rm_mask_right	= $('#rm_mask_right'),
	$rm_corner_left	= $('#rm_corner_left'),
	$rm_corner_right= $('#rm_corner_right'),

	//check if the browser is &lt;= IE8
	ieLte8			= ($.browser.msie &#038;&#038; parseInt($.browser.version) &lt;= 8),
</pre>
<p>Then we will define our main function:</p>
<pre class="brush:js">
RotateImageMenu	= (function() {
...
})();

RotateImageMenu.init();
</pre>
<p>And then we define the following in our function:</p>
<pre class="brush:js">
	//difference of animation time between the items
var	timeDiff			= 300,
	//time between each image animation (slideshow)
	slideshowTime		= 3000,
	slideshowInterval,
	//checks if the images are rotating
	isRotating			= false,
	//how many images completed each slideshow iteration
	completed			= 0,
	/*
	all our images have 310 of width and 465 of height.
	this could / should be dynamically calculated
	if we would have different image sizes.

	we will set the rotation origin at
	x = width/2 and y = height*2
	*/
	origin				= ['155px', '930px'],
	init				= function() {
		configure();
		initEventsHandler();
	},
	//initialize some events
	initEventsHandler	= function() {
		/*
		next and previous arrows:
		we will stop the slideshow if active,
		and rotate each items images.
		1 	rotate right
		-1 	rotate left
		*/
		$rm_next.bind('click', function(e) {
			stopSlideshow();
			rotateImages(1);
			return false;
		});
		$rm_prev.bind('click', function(e) {
			stopSlideshow();
			rotateImages(-1);
			return false;
		});
		/*
		start and stop the slideshow
		*/
		$rm_play.bind('click', function(e) {
			startSlideshow();
			return false;
		});
		$rm_pause.bind('click', function(e) {
			stopSlideshow();
			return false;
		});
		/*
		adds events to the mouse and left / right keys
		*/
		$(document).bind('mousewheel', function(e, delta) {
			if(delta &gt; 0) {
				stopSlideshow();
				rotateImages(0);
			}
			else {
				stopSlideshow();
				rotateImages(1);
			}
			return false;
		}).keydown(function(e){
			switch(e.which){
				case 37:
					stopSlideshow();
					rotateImages(0);
					break;
				case 39:
					stopSlideshow();
					rotateImages(1);
					break;
			}
		});
	},
	/*
	rotates each items images.
	we set a delay between each item animation
	*/
	rotateImages		= function(dir) {
		//if the animation is in progress return
		if(isRotating) return false;

		isRotating = true;

		$listItems.each(function(i) {
			var $item 				= $(this),
				/*
				the delay calculation.
				if rotation is to the right,
				then the first item to rotate is the first one,
				otherwise the last one
				*/
				interval			= (dir === 1) ? i * timeDiff : (totalItems - 1 - i) * timeDiff;

			setTimeout(function() {
					//the images associated to this item
				var	$otherImages		= $('#' + $item.data('images')).children('img'),
					totalOtherImages	= $otherImages.length;

					//the current one
					$img				= $item.children('img:last'),
					//keep track of each items current image
					current				= $item.data('current');
					//out of bounds
					if(current &gt; totalOtherImages - 1)
						current = 0;
					else if(current &lt; 0)
						current = totalOtherImages - 1;

					//the next image to show and its
					//initial rotation (depends on dir)
					var otherRotation	= (dir === 1) ? '-30deg' : '30deg',
						$other			= $otherImages.eq(current).clone();

					//for IE &lt;= 8 we will not rotate,
					//but fade out / fade in ...
					//better than nothing :)
					if(!ieLte8)
						$other.css({
							rotate	: otherRotation,
							origin	: origin
						});

					(dir === 1) ? ++current : --current;

					//prepend the next image to the &lt;li&gt;
					$item.data('current', current).prepend($other);

					//the final rotation for the current image
					var rotateTo		= (dir === 1) ? '80deg' : '-80deg';

					if(!ieLte8) {
						$img.animate({
							rotate	: rotateTo
						}, 1200, function(){
							$(this).remove();
							++completed;
							if(completed === 4) {
								completed = 0;
								isRotating = false;
							}
						});
						$other.animate({
							rotate	: '0deg'
						}, 600);
					}
					else {
						$img.fadeOut(1200, function(){
							$(this).remove();
							++completed;
							if(completed === 4) {
								completed = 0;
								isRotating = false;
							}
						});
					}

			}, interval );
		});

	},
	//set initial rotations
	configure			= function() {
		if($.browser.msie &#038;&#038; !ieLte8)
			rotateMaskCorners();
		else if(ieLte8)
			hideMaskCorners();

		$listItems.each(function(i) {
			//the initial current is 1
			//since we already showing the first image
			var $item = $(this).data('current', 1);

			if(!ieLte8)
			$item.transform({rotate: $item.data('rotation') + 'deg'})
				 .find('img')
				 .transform({origin: origin});
		});
	},
	//rotates the masks and corners
	rotateMaskCorners	= function() {
		$rm_mask_left.transform({rotate: '-3deg'});
		$rm_mask_right.transform({rotate: '3deg'});
		$rm_corner_left.transform({rotate: '45deg'});
		$rm_corner_right.transform({rotate: '-45deg'});
	},
	//hides the masks and corners
	hideMaskCorners		= function() {
		$rm_mask_left.hide();
		$rm_mask_right.hide();
		$rm_corner_left.hide();
		$rm_corner_right.hide();
	},
	startSlideshow		= function() {
		clearInterval(slideshowInterval);
		rotateImages(1);
		slideshowInterval	= setInterval(function() {
			rotateImages(1);
		}, slideshowTime);
		//show the pause button and hide the play button
		$rm_play.hide();
		$rm_pause.show();
	},
	stopSlideshow		= function() {
		clearInterval(slideshowInterval);
		//show the play button and hide the pause button
		$rm_pause.hide();
		$rm_play.show();
	};

return {init : init};
</pre>
<p>As you noticed, we will treat older browsers a bit differently so that the slider works properly. </p>
<p>And that&#8217;s it! We really hope you enjoyed the tutorial and like the result!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/RotatingImageSlider/" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/RotatingImageSlider/RotatingImageSlider.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/04/28/rotating-image-slider/feed/</wfw:commentRss>
		<slash:comments>126</slash:comments>
		</item>
		<item>
		<title>Rocking and Rolling Rounded Menu with jQuery</title>
		<link>http://tympanus.net/codrops/2010/04/30/rocking-and-rolling-rounded-menu-with-jquery/</link>
		<comments>http://tympanus.net/codrops/2010/04/30/rocking-and-rolling-rounded-menu-with-jquery/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 14:00:48 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[rotating]]></category>
		<category><![CDATA[rounded]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=1941</guid>
		<description><![CDATA[View demoDownload source In this tutorial we are going to make use of the incredibly awesome rotating and scaling jQuery patch from Zachary Johnson that can be found here. We will create a menu with little icons that will rotate when hovering. Also, we will make the menu item expand and reveal some menu content, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/RockingRollingMenu/" target="_blank"><img class="aligncenter size-full wp-image-1942" title="rockroll" src="http://tympanus.net/codrops/wp-content/uploads/2010/04/rockroll.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/RockingRollingMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/RockingRollingMenu/RockingRollingMenu.zip">Download source</a></p>
<p>In this tutorial we are going to make use of the incredibly awesome rotating and scaling jQuery patch from Zachary Johnson that can be found <a href="http://www.zachstronaut.com/posts/2009/08/07/jquery-animate-css-rotate-scale.html" target="_blank">here</a>.<a href="http://www.zachstronaut.com/posts/2009/08/07/jquery-animate-css-rotate-scale.html" target="_blank"></a> We will create a menu with little icons that will rotate when hovering. Also, we will make the menu item expand and reveal some menu content, like links or a search box.</p>
<p>Ok, so let&#8217;s get started, it&#8217;s less complicated than it looks.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>For this menu we will not create a list, but div elements for each menu item. We will pack the menu items in a main div called <strong>menu</strong>. Each item will have an icon as link element and a content div with the heading and a paragraph where we will add links or a search box:</p>
<pre class="brush:xml">&lt;div class="menu"&gt;
	&lt;div class="item"&gt;
		&lt;a class="link icon_mail"&gt;&lt;/a&gt;
		&lt;div class="item_content"&gt;
			&lt;h2&gt;Contact us&lt;/h2&gt;
			&lt;p&gt;
				&lt;a href="#"&gt;eMail&lt;/a&gt;
				&lt;a href="#"&gt;Twitter&lt;/a&gt;
				&lt;a href="#"&gt;Facebook&lt;/a&gt;
			&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="item"&gt;
		&lt;a class="link icon_help"&gt;&lt;/a&gt;
		&lt;div class="item_content"&gt;
			&lt;h2&gt;Help&lt;/h2&gt;
			&lt;p&gt;
				&lt;a href="#"&gt;FAQ&lt;/a&gt;
				&lt;a href="#"&gt;Live Support&lt;/a&gt;
				&lt;a href="#"&gt;Tickets&lt;/a&gt;
			&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="item"&gt;
		&lt;a class="link icon_find"&gt;&lt;/a&gt;
		&lt;div class="item_content"&gt;
			&lt;h2&gt;Search&lt;/h2&gt;
			&lt;p&gt;
				&lt;input type="text"&gt;&lt;/input&gt;
				&lt;a href=""&gt;Go&lt;/a&gt;
			&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="item"&gt;
		&lt;a class="link icon_photos"&gt;&lt;/a&gt;
		&lt;div class="item_content"&gt;
			&lt;h2&gt;Image Gallery&lt;/h2&gt;
			&lt;p&gt;
				&lt;a href="#"&gt;Categories&lt;/a&gt;
				&lt;a href="#"&gt;Archives&lt;/a&gt;
				&lt;a href="#"&gt;Featured&lt;/a&gt;
			&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="item"&gt;
		&lt;a class="link icon_home"&gt;&lt;/a&gt;
		&lt;div class="item_content"&gt;
			&lt;h2&gt;Start from here&lt;/h2&gt;
			&lt;p&gt;
				&lt;a href="#"&gt;Services&lt;/a&gt;
				&lt;a href="#"&gt;Portfolio&lt;/a&gt;
				&lt;a href="#"&gt;Pricing&lt;/a&gt;
			&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Initially, the item div will be just as big to surround the icon, we will make it expand then and we will reveal the content afterward.</p>
<h3>The CSS</h3>
<p>The general style for the menu like the font will be defined as follows:</p>
<pre class="brush:css">.menu{
    width:800px;
    height:52px;
    position:relative;
    top:200px;
    left:100px;
    font-family: "Trebuchet MS", sans-serif;
    font-size: 16px;
    font-style: normal;
    font-weight: bold;
    text-transform: uppercase;
}
</pre>
<p>The items inside of the menu will be floating right, since we want the items to expand to the left and push the other items away:</p>
<pre class="brush:css">.item{
    position:relative;
    background-color:#f0f0f0;
    float:right;
    width:52px;
    margin:0px 5px;
    height:52px;
    border:2px solid #ddd;
    -moz-border-radius:30px;
    -webkit-border-radius:30px;
    border-radius:30px;
    -moz-box-shadow:1px 1px 3px #555;
    -webkit-box-shadow:1px 1px 3px #555;
    box-shadow:1px 1px 3px #555;
    cursor:pointer;
    overflow:hidden;
}
</pre>
<p>Then we define the style of the icons (the link class) in the following way:</p>
<pre class="brush:css">.link{
    left:2px;
    top:2px;
    position:absolute;
    width:48px;
    height:48px;
}
.icon_home{
    background:transparent url(../images/home.png) no-repeat top left;
}
.icon_mail{
    background:transparent url(../images/mail.png) no-repeat top left;
}
.icon_help{
    background:transparent url(../images/help.png) no-repeat top left;
}
.icon_find{
    background:transparent url(../images/find.png) no-repeat top left;
}
.icon_photos{
    background:transparent url(../images/photos.png) no-repeat top left;
}
</pre>
<p>The other content elements we will style as follows:</p>
<pre class="brush:css">.item_content{
    position:absolute;
    height:52px;
    width:220px;
    overflow:hidden;
    left:56px;
    top:7px;
    background:transparent;
    display:none;
}
.item_content h2{
    color:#aaa;
    text-shadow: 1px 1px 1px #fff;
    background-color:transparent;
    font-size:14px;
}
.item_content a{
    background-color:transparent;
    float:left;
    margin-right:7px;
    margin-top:3px;
    color:#bbb;
    text-shadow: 1px 1px 1px #fff;
    text-decoration:none;
    font-size:12px;
}
.item_content a:hover{
    color:#0b965b;
}
.item_content p {
    background-color:transparent;
    display:none;
}
.item_content p input{
    border:1px solid #ccc;
    padding:1px;
    width:155px;
    float:left;
    margin-right:5px;
}
</pre>
<p>With a white text-shadow we can create a nice engraved text effect.<br />
Ok, let&#8217;s add some magic.</p>
<h3>The JavaScript</h3>
<p>First, we need to add the script inclusions of jQuery and the other two scripts of Zachary.<br />
Then we will add the following functions:</p>
<pre class="brush:js">$('.item').hover(
	function(){
		var $this = $(this);
		expand($this);
	},
	function(){
		var $this = $(this);
		collapse($this);
	}
);
function expand($elem){
	var angle = 0;
	var t = setInterval(function () {
		if(angle == 1440){
			clearInterval(t);
			return;
		}
		angle += 40;
		$('.link',$elem).stop().animate({rotate: '+=-40deg'}, 0);
	},10);
	$elem.stop().animate({width:'268px'}, 1000)
	.find('.item_content').fadeIn(400,function(){
		$(this).find('p').stop(true,true).fadeIn(600);
	});
}
function collapse($elem){
	var angle = 1440;
	var t = setInterval(function () {
		if(angle == 0){
			clearInterval(t);
			return;
		}
		angle -= 40;
		$('.link',$elem).stop().animate({rotate: '+=40deg'}, 0);
	},10);
	$elem.stop().animate({width:'52px'}, 1000)
	.find('.item_content').stop(true,true).fadeOut()
          .find('p').stop(true,true).fadeOut();
}
</pre>
<p>To make things easier, we created two functions, one for expanding an item and one for collapsing it. The expand function will make the icon rotate 4 times around itself (360 times 4 are 1440). We will also make the item expand by animating an increase in its width. Then, we let the content appear, first the whole div and then the paragraph element.</p>
<p>The collapse function will rotate the icon back, decrease the width of the item and make the content disappear.</p>
<p>And that&#8217;s it! I hope you enjoyed it!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/RockingRollingMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/RockingRollingMenu/RockingRollingMenu.zip">Download source</a></p>
<p><!-- wp_ad_camp_1 --></p>
<div class="partner_section_post"><span>Message from Testking</span>Join <a href="http://www.testkingsite.com/cisco/642-384.html">testking 642-384</a> web designing course to learn how to design successful websites using css and jQuery. Download <a href="http://www.testkingsite.com/microsoft/70-646.html">testking 70-646</a> and <a href="http://www.testkingsite.com/cisco/642-504.html">testking 642-504</a> tutorials to get useful information on latest web design practices.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/04/30/rocking-and-rolling-rounded-menu-with-jquery/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
		<item>
		<title>Creating a Rotating Billboard System with jQuery and CSS</title>
		<link>http://tympanus.net/codrops/2009/12/16/creating-a-rotating-billboard-system-with-jquery-and-css/</link>
		<comments>http://tympanus.net/codrops/2009/12/16/creating-a-rotating-billboard-system-with-jquery-and-css/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 17:19:42 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[billboard]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[rotating]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=1046</guid>
		<description><![CDATA[View demoDownload source Currently we are in the &#8220;hey, let&#8217;s do that flash thing in jQuery&#8221;-mood and so we came up with another idea: a rotating billboard system. In this tutorial we will use some images, CSS and jQuery to create the effect of a rotating billboard with two ads. The idea is to make [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1048 aligncenter" title="billboard" src="http://tympanus.net/codrops/wp-content/uploads/2009/12/billboard.gif" alt="billboard" width="520" height="303" /></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/Billboard/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/Billboard/Billboard.zip">Download source</a></p>
<p>Currently we are in the &#8220;hey, let&#8217;s do that flash thing in jQuery&#8221;-mood and so we came up with another idea: a rotating billboard system.</p>
<p>In this tutorial we will use some images, CSS and jQuery to create the effect of a rotating billboard with two ads. The idea is to make one set of image slices disappear while another one (the other ad) appear. We will decrease the width of each disappearing slice and increase the width of each appearing slice. This will give the effect of rotating slices, just like in a rotating billboard system.</p>
<p>Ok, let&#8217;s start coding!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>1. The HTML</h3>
<p>We will have quite a lot of markup for the image slices &#8211;  it will be 22 slices for each ad:</p>
<pre class="brush:xml">
&lt;div class="container"&gt;
	&lt;div class="ad"&gt;
		&lt;div id="ad_1" class="ad_1"&gt;
			&lt;img class="slice_1" src="ads/ad1_slice01.jpg"/&gt;
			&lt;img class="slice_2" src="ads/ad1_slice02.jpg"/&gt;
			&lt;img class="slice_3" src="ads/ad1_slice03.jpg"/&gt;
			&lt;img class="slice_4" src="ads/ad1_slice04.jpg"/&gt;
			&lt;img class="slice_5" src="ads/ad1_slice05.jpg"/&gt;
			&lt;img class="slice_6" src="ads/ad1_slice06.jpg"/&gt;
			&lt;img class="slice_7" src="ads/ad1_slice07.jpg"/&gt;
			&lt;img class="slice_8" src="ads/ad1_slice08.jpg"/&gt;
			&lt;img class="slice_9" src="ads/ad1_slice09.jpg"/&gt;
			&lt;img class="slice_10" src="ads/ad1_slice10.jpg"/&gt;
			&lt;img class="slice_11" src="ads/ad1_slice11.jpg"/&gt;
			&lt;img class="slice_12" src="ads/ad1_slice12.jpg"/&gt;
			&lt;img class="slice_13" src="ads/ad1_slice13.jpg"/&gt;
			&lt;img class="slice_14" src="ads/ad1_slice14.jpg"/&gt;
			&lt;img class="slice_15" src="ads/ad1_slice15.jpg"/&gt;
			&lt;img class="slice_16" src="ads/ad1_slice16.jpg"/&gt;
			&lt;img class="slice_17" src="ads/ad1_slice17.jpg"/&gt;
			&lt;img class="slice_18" src="ads/ad1_slice18.jpg"/&gt;
			&lt;img class="slice_19" src="ads/ad1_slice19.jpg"/&gt;
			&lt;img class="slice_20" src="ads/ad1_slice20.jpg"/&gt;
			&lt;img class="slice_21" src="ads/ad1_slice21.jpg"/&gt;
			&lt;img class="slice_22" src="ads/ad1_slice22.jpg"/&gt;
		&lt;/div&gt;
		&lt;div id="ad_2" class="ad_2"&gt;
			&lt;img class="slice_1" src="ads/ad2_slice01.jpg"/&gt;
			&lt;img class="slice_2" src="ads/ad2_slice02.jpg"/&gt;
			&lt;img class="slice_3" src="ads/ad2_slice03.jpg"/&gt;
			&lt;img class="slice_4" src="ads/ad2_slice04.jpg"/&gt;
			&lt;img class="slice_5" src="ads/ad2_slice05.jpg"/&gt;
			&lt;img class="slice_6" src="ads/ad2_slice06.jpg"/&gt;
			&lt;img class="slice_7" src="ads/ad2_slice07.jpg"/&gt;
			&lt;img class="slice_8" src="ads/ad2_slice08.jpg"/&gt;
			&lt;img class="slice_9" src="ads/ad2_slice09.jpg"/&gt;
			&lt;img class="slice_10" src="ads/ad2_slice10.jpg"/&gt;
			&lt;img class="slice_11" src="ads/ad2_slice11.jpg"/&gt;
			&lt;img class="slice_12" src="ads/ad2_slice12.jpg"/&gt;
			&lt;img class="slice_13" src="ads/ad2_slice13.jpg"/&gt;
			&lt;img class="slice_14" src="ads/ad2_slice14.jpg"/&gt;
			&lt;img class="slice_15" src="ads/ad2_slice15.jpg"/&gt;
			&lt;img class="slice_16" src="ads/ad2_slice16.jpg"/&gt;
			&lt;img class="slice_17" src="ads/ad2_slice17.jpg"/&gt;
			&lt;img class="slice_18" src="ads/ad2_slice18.jpg"/&gt;
			&lt;img class="slice_19" src="ads/ad2_slice19.jpg"/&gt;
			&lt;img class="slice_20" src="ads/ad2_slice20.jpg"/&gt;
			&lt;img class="slice_21" src="ads/ad2_slice21.jpg"/&gt;
			&lt;img class="slice_22" src="ads/ad2_slice22.jpg"/&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;div class="billboard"&gt;&lt;/div&gt;
</pre>
<p>For these images, 22 slices (each slice 35 pixels wide) of a 770 pixel wide and 340 pixel high image were made. One might think that this is a lot of work and that we could actually take one whole picture and create divs acting like the slices with that background image and the right background position. But then we would not be able to create the same effect of a rotating slice (at least not with the JavaScript we created for this showcase). </p>
<p>The billboard will be an absolute positioned div with the billboard image. Since the image has some transparent spotlights, we want to lay it over the ad container.</p>
<h3>2. The CSS</h3>
<p>The style for the billboard frame will be the following:</p>
<pre class="brush:css">
.billboard{
    position:absolute;
    bottom:0px;
    left:50%;
    margin-left:-447px;
    width:916px;
    height:599px;
    background:transparent url(../images/billboard.png) no-repeat 0px 0px;
}
</pre>
<p>To position the element in the center of the page, we set the left value to 50% and the left margin negatively to half of the width of the element. </p>
<p>The container for the ads will have the same style like the billboard, except the background-image. We do that, because we need to position the containing elements at the same place like the billboard. We don&#8217;t want to place the ads inside of the billboard because we need the billboard to be on top of them. So, we do this trick and create another element with the same positioning:</p>
<pre class="brush:css">
.container{
    position:absolute;
    bottom:0px;
    left:50%;
    margin-left:-447px;
    width:916px;
    height:599px;
}
.ad{
    width:800px;
    height:336px;
    position:relative;
    margin:35px 0px 0px 60px;
    background-color:#333;
}
.ad_1 img{
    width:35px;
    height:336px;
    position:absolute;
}
.ad_2 img{
    width:0px;
    height:336px;
    margin-left:18px;
    position:absolute;
}
</pre>
<p>The slices of the ad images will be 35 pixels wide. The slices of the second ad will have the same width, but initially we need to set it to 0. We also need to set the left margin of the second slices to 18 pixels since we want to create the rotating effect. I will explain more about this value after we define the CSS for the slices.</p>
<p>The single slices need to be positioned:</p>
<pre class="brush:css">
.slice_1{left:0px;}
.slice_2{left:36px;}
.slice_3{left:72px;}
.slice_4{left:108px;}
.slice_5{left:144px;}
.slice_6{left:180px;}
.slice_7{left:216px;}
.slice_8{left:252px;}
.slice_9{left:288px;}
.slice_10{left:324px;}
.slice_11{left:360px;}
.slice_12{left:396px;}
.slice_13{left:432px;}
.slice_14{left:468px;}
.slice_15{left:504px;}
.slice_16{left:540px;}
.slice_17{left:576px;}
.slice_18{left:612px;}
.slice_19{left:648px;}
.slice_20{left:684px;}
.slice_21{left:720px;}
.slice_22{left:756px;}
</pre>
<p>By positioning the elements one more pixel to the left than they are actually wide, we create a little gap between the them. Now, the left margin has a value of 18 pixels because it is half of a slice plus its gap. We set this because we want the slices to appear (or disappear) from (or to) their center and not just from the side. If we simply set the width of a slice to 0 pixels the image will not seem to be rotating.</p>
<p>And that is all the CSS. For the additional fancy background images you can check out the downloadable version below.</p>
<p>Let&#8217;s create the rotating effect with jQuery.</p>
<h3>3. The JavaScript</h3>
<p>We will now create a function for rotating the slices. The function will make the first ad slices disappear by making their width 0 pixels. To achieve the rotating effect, we add a left margin of 18 pixels. </p>
<p>While the first ad slices disappear we make the others appear by removing the left margin of 18 pixels (that we initially set in the CSS) and giving them a width of 35 pixels. We call the rotate function like this:</p>
<pre class="brush:js">
 $('#ad_1 > img').each(function(i,e){
        rotate($(this),500,3000,i);
    });
</pre>
<p>The whole script that we call will look like this:</p>
<pre class="brush:js">
$(function() {
    $('#ad_1 > img').each(function(i,e){
        rotate($(this),500,3000,i);
    });
    function rotate(elem1,speed,timeout,i){
        elem1.animate({'marginLeft':'18px','width':'0px'},speed,function(){
            var other;
            if(elem1.parent().attr('id') == 'ad_1')
                other = $('#ad_2').children('img').eq(i);
            else
                other = $('#ad_1').children('img').eq(i);
                other.animate({'marginLeft':'0px','width':'35px'},
                                  speed,function(){
                var f = function() { rotate(other,speed,timeout,i) };
                setTimeout(f,timeout);
            });
        });
    }
});
</pre>
<p>So, the rotate function performs the hiding of the current element (that it was called upon) and then identifies which element it&#8217;s currently dealing with, so that another call of the rotate function can be performed on the other ad slices.<br />
The two times mentioned in the rotate function stand for the speed of the rotation effect (speed) and the duration between the swapping of the ads (timeout) in milliseconds.</p>
<p>And that&#8217;s it!<br />
I hope you like and enjoy it! </p>
<p><a class="demo" href="http://tympanus.net/Tutorials/Billboard/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/Billboard/Billboard.zip">Download source</a></p>
<p><!-- wp_ad_camp_1 --></p>
<div class="partner_section_post"><span>Message from Testking</span>Whether  you want to get <a href="http://www.pass4sure.com/CCNP.html">ccnp certification</a>  or interested in <a href="http://www.pass4sure.com/CCNA.html">ccna certification</a>, using <a href="http://www.pass4sure.com/CCNA-Wireless.html">ccna wireless</a> prep resources you will pass real exam on first attempt.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2009/12/16/creating-a-rotating-billboard-system-with-jquery-and-css/feed/</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  tympanus.net/codrops/tag/rotating/feed/ ) in 0.23183 seconds, on Feb 8th, 2012 at 5:25 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 8th, 2012 at 6:25 pm UTC -->
