<?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; sliding</title>
	<atom:link href="http://tympanus.net/codrops/tag/sliding/feed/" rel="self" type="application/rss+xml" />
	<link>http://tympanus.net/codrops</link>
	<description>Useful resources and inspiration for creative minds</description>
	<lastBuildDate>Wed, 23 May 2012 09:46:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Sliding Image Panels with CSS3</title>
		<link>http://tympanus.net/codrops/2012/01/17/sliding-image-panels-with-css3/</link>
		<comments>http://tympanus.net/codrops/2012/01/17/sliding-image-panels-with-css3/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 12:51:47 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[background-image]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[general sibling selector]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[transition]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=7286</guid>
		<description><![CDATA[Today we'll show you how to create some neat sliding image panels with CSS only. The idea is to use background images for the panels and animate them when clicking on a label. We'll use radio buttons with labels and target the respective panels with the general sibling selector. ]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/"><br />
<img class="alignnone size-full wp-image-7366" src="http://tympanus.net/codrops/wp-content/uploads/2012/01/SlidingImagePanelsCss3_2.jpg" alt="SlidingImagePanelsCss3_2" width="580" height="315" /><br />
</a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/CSS3SlidingImagePanels.zip">Download source</a></p>
<p>Today we&#8217;ll show you how to create some neat sliding image panels with CSS only. The idea is to use background images for the panels and animate them when clicking on a label. We&#8217;ll use radio buttons with labels and target the respective panels with the general sibling selector.</p>
<p>The beautiful images are by <a href="http://www.behance.net/qstra">Joanna Kustra</a> and they are licensed under the <a href="http://creativecommons.org/licenses/by-nc/3.0/">Attribution-NonCommercial 3.0 Unported Creative Commons License</a>.</p>
<p>You might as well be interested in <a href="http://tympanus.net/codrops/2012/01/09/filter-functionality-with-css3/">Filter Functionality with CSS3 </a> where we have used a similar technique for filtering elements based on their type.</p>
<p><strong>Please note: the result of this tutorial will only work as intended in browsers that support CSS transitions and animations.</strong></p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML will consist of three major parts: the radio buttons and the labels, the container with the panels and their &#8220;slices&#8221; for each image, and the titles. The container with the class <strong>cr-bgimg</strong> part will have a division for each of the panels and inside we&#8217;ll place spans for every image with the right background position. So, the first panel will have four slices, each having the one of the images as background with the left-most position. The second panel will have again four slices but now the background position will be moved to be showing the next part of the respective image:</p>
<pre class="brush:xml">&lt;section class="cr-container"&gt;			

	&lt;!-- radio buttons and labels --&gt;
	&lt;input id="select-img-1" name="radio-set-1" type="radio" class="cr-selector-img-1" checked/&gt;
	&lt;label for="select-img-1" class="cr-label-img-1"&gt;1&lt;/label&gt;

	&lt;input id="select-img-2" name="radio-set-1" type="radio" class="cr-selector-img-2" /&gt;
	&lt;label for="select-img-2" class="cr-label-img-2"&gt;2&lt;/label&gt;

	&lt;input id="select-img-3" name="radio-set-1" type="radio" class="cr-selector-img-3" /&gt;
	&lt;label for="select-img-3" class="cr-label-img-3"&gt;3&lt;/label&gt;

	&lt;input id="select-img-4" name="radio-set-1" type="radio" class="cr-selector-img-4" /&gt;
	&lt;label for="select-img-4" class="cr-label-img-4"&gt;4&lt;/label&gt;

	&lt;div class="clr"&gt;&lt;/div&gt;	

	&lt;!-- panels --&gt;
	&lt;div class="cr-bgimg"&gt;
		&lt;div&gt;
			&lt;span&gt;Slice 1 - Image 1&lt;/span&gt;
			&lt;span&gt;Slice 1 - Image 2&lt;/span&gt;
			&lt;span&gt;Slice 1 - Image 3&lt;/span&gt;
			&lt;span&gt;Slice 1 - Image 4&lt;/span&gt;
		&lt;/div&gt;
		&lt;div&gt;
			&lt;span&gt;Slice 2 - Image 1&lt;/span&gt;
			&lt;span&gt;Slice 2 - Image 2&lt;/span&gt;
			&lt;span&gt;Slice 2 - Image 3&lt;/span&gt;
			&lt;span&gt;Slice 2 - Image 4&lt;/span&gt;
		&lt;/div&gt;
		&lt;div&gt;
			&lt;span&gt;Slice 3 - Image 1&lt;/span&gt;
			&lt;span&gt;Slice 3 - Image 2&lt;/span&gt;
			&lt;span&gt;Slice 3 - Image 3&lt;/span&gt;
			&lt;span&gt;Slice 3 - Image 4&lt;/span&gt;
		&lt;/div&gt;
		&lt;div&gt;
			&lt;span&gt;Slice 4 - Image 1&lt;/span&gt;
			&lt;span&gt;Slice 4 - Image 2&lt;/span&gt;
			&lt;span&gt;Slice 4 - Image 3&lt;/span&gt;
			&lt;span&gt;Slice 4 - Image 4&lt;/span&gt;
		&lt;/div&gt;
	&lt;/div&gt;

	&lt;!-- titles --&gt;
	&lt;div class="cr-titles"&gt;
		&lt;h3&gt;
			&lt;span&gt;Serendipity&lt;/span&gt;
			&lt;span&gt;What you've been dreaming of&lt;/span&gt;
		&lt;/h3&gt;
		&lt;h3&gt;
			&lt;span&gt;Adventure&lt;/span&gt;
			&lt;span&gt;Where the fun begins&lt;/span&gt;
		&lt;/h3&gt;
		&lt;h3&gt;
			&lt;span&gt;Nature&lt;/span&gt;
			&lt;span&gt;Unforgettable eperiences&lt;/span&gt;
		&lt;/h3&gt;
		&lt;h3&gt;
			&lt;span&gt;Serenity&lt;/span&gt;
			&lt;span&gt;When silence touches nature&lt;/span&gt;
		&lt;/h3&gt;
	&lt;/div&gt;

&lt;/section&gt;</pre>
<p>The h3 elements for the titles will have two spans, one for the main headline and one for the sub-headline.</p>
<p>Let&#8217;s style this baby.</p>
<h3>The CSS</h3>
<p><em>I will omit all the vendor prefixes, but you will, of course, find them in the files.</em><br />
<em>We&#8217;ll be going through the style of demo 1.</em></p>
<p>Our aim is to first hide those radio buttons by covering them up with labels. In web browsers, clicking on a label will make the respective checkbox or radio button selected. Giving an ID to the input, we can use the <a href="http://www.w3.org/TR/html4/interact/forms.html#adef-for">for = idref</a> attribute of the label to reference the respective input.</p>
<p>Second, we want to place all the background images correctly and third, we want to show the respective image slices and titles when clicking on a label.</p>
<p>So, lets first syle the section and give it a white border with some subtle box box shadow:</p>
<pre class="brush:css">.cr-container{
	width: 600px;
	height: 400px;
	position: relative;
	margin: 0 auto;
	border: 20px solid #fff;
	box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}</pre>
<p>Since we want to use the general sibling selector in order to &#8220;reach&#8221; the right image slices and titles, we need to place the labels before those containers. Let&#8217;s make sure that they are on top as a layer (z-index) and push its position down by adding a top margin of 350px;</p>
<pre class="brush:css">.cr-container label{
	font-style: italic;
	width: 150px;
	height: 30px;
	cursor: pointer;
	color: #fff;
	line-height: 32px;
	font-size: 24px;
	float:left;
	position: relative;
	margin-top: 350px;
	z-index: 1000;
}</pre>
<p>Let&#8217;s prettify the label by adding a little circle. We&#8217;ll create a pseudo element and place it centered behind the label text:</p>
<pre class="brush:css">.cr-container label:before{
	content:'';
	width: 34px;
	height: 34px;
	background: rgba(130,195,217,0.9);
	position: absolute;
	left: 50%;
	margin-left: -17px;
	border-radius: 50%;
	box-shadow: 0px 0px 0px 4px rgba(255,255,255,0.3);
	z-index:-1;
}</pre>
<p>In order to create a separation between the panels we&#8217;ll use a little trick. We&#8217;ll create another pseudo-element for the label and extend it to stretch over the panel. Using a gradient, we&#8217;ll make the line &#8220;fade out&#8221; at the top:</p>
<pre class="brush:css">.cr-container label:after{
	width: 1px;
	height: 400px;
	content: '';
	background: linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%);
	position: absolute;
	bottom: -20px;
	right: 0px;
}</pre>
<p>The last panel should not have that line so we simply give it 0 width:</p>
<pre class="brush:css">.cr-container label.cr-label-img-4:after{
	width: 0px;
}</pre>
<p>Now, that we&#8217;ve taken care of the label look, we can hide the inputs:</p>
<pre class="brush:css">.cr-container input{
	display: none;
}</pre>
<p>Whenever we click on a label, the respective input gets checked. Now we can target the respective label using the general sibling selector. So, we will change the color the &#8220;selected&#8221; label:</p>
<pre class="brush:css">.cr-container input.cr-selector-img-1:checked ~ label.cr-label-img-1,
.cr-container input.cr-selector-img-2:checked ~ label.cr-label-img-2,
.cr-container input.cr-selector-img-3:checked ~ label.cr-label-img-3,
.cr-container input.cr-selector-img-4:checked ~ label.cr-label-img-4{
	color: #68abc2;
}</pre>
<p>And we&#8217;ll also change the background color and box shadow of its cicle pseudo-element:</p>
<pre class="brush:css">.cr-container input.cr-selector-img-1:checked ~ label.cr-label-img-1:before,
.cr-container input.cr-selector-img-2:checked ~ label.cr-label-img-2:before,
.cr-container input.cr-selector-img-3:checked ~ label.cr-label-img-3:before,
.cr-container input.cr-selector-img-4:checked ~ label.cr-label-img-4:before{
	background: #fff;
	box-shadow: 0px 0px 0px 4px rgba(104,171,194,0.6);
}</pre>
<p>The container for the image panels will occupy all the width and it will be positioned absolutely. This container will be used later in order to set the background image to the currently selected image. We need to do this in order to have an image visible by default. So we&#8217;ll also add some background properties already:</p>
<pre class="brush:css">.cr-bgimg{
	width: 600px;
	height: 400px;
	position: absolute;
	left: 0px;
	top: 0px;
	z-index: 1;
	background-repeat: no-repeat;
	background-position: 0 0;
}</pre>
<p>Since we have four panels/images, one panel will have the width of 150 pixels (600 divided by 4). The panels will be floating left and we&#8217;ll hide their overflow since we don&#8217;t want to see the slices coming out when we slide them:</p>
<pre class="brush:css">.cr-bgimg div{
	width: 150px;
	height: 100%;
	position: relative;
	float: left;
	overflow: hidden;
	background-repeat: no-repeat;
}</pre>
<p>Each slice span will be positioned absolutely and initially, they will be hidden by placing them out of the panel with a left of -150px:</p>
<pre class="brush:css">.cr-bgimg div span{
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0px;
	left: -150px;
	z-index: 2;
	text-indent: -9000px;
}</pre>
<p>Now, let&#8217;s take care of the background of the image container and the respective image slices:</p>
<pre class="brush:css">.cr-container input.cr-selector-img-1:checked ~ .cr-bgimg,
.cr-bgimg div span:nth-child(1){
	background-image: url(../images/1.jpg);
}
.cr-container input.cr-selector-img-2:checked ~ .cr-bgimg,
.cr-bgimg div span:nth-child(2){
	background-image: url(../images/2.jpg);
}
.cr-container input.cr-selector-img-3:checked ~ .cr-bgimg,
.cr-bgimg div span:nth-child(3){
	background-image: url(../images/3.jpg);
}
.cr-container input.cr-selector-img-4:checked ~ .cr-bgimg,
.cr-bgimg div span:nth-child(4){
	background-image: url(../images/4.jpg);
}</pre>
<p>We also need to give the right background position to the slices depending on the panel:</p>
<pre class="brush:css">.cr-bgimg div:nth-child(1) span{
	background-position: 0px 0px;
}
.cr-bgimg div:nth-child(2) span{
	background-position: -150px 0px;
}
.cr-bgimg div:nth-child(3) span{
	background-position: -300px 0px;
}
.cr-bgimg div:nth-child(4) span{
	background-position: -450px 0px;
}</pre>
<p>When we click on a label we will simply slide all the slices out to the right:</p>
<pre class="brush:css">.cr-container input:checked ~ .cr-bgimg div span{
	animation: slideOut 0.6s ease-in-out;
}
@keyframes slideOut{
	0%{
		left: 0px;
	}
	100%{
		left: 150px;
	}
}</pre>
<p>&#8230;all except the slices with the respective background image. Those will slide in from -150px to 0px:</p>
<pre class="brush:css">.cr-container input.cr-selector-img-1:checked ~ .cr-bgimg div span:nth-child(1),
.cr-container input.cr-selector-img-2:checked ~ .cr-bgimg div span:nth-child(2),
.cr-container input.cr-selector-img-3:checked ~ .cr-bgimg div span:nth-child(3),
.cr-container input.cr-selector-img-4:checked ~ .cr-bgimg div span:nth-child(4)
{
	transition: left 0.5s ease-in-out;
	animation: none;
	left: 0px;
	z-index: 10;
}</pre>
<p>Last, but not least, we want to style the h3 title elements and their spans. The h3 will have a opacity transition and once we select the respective label/input the opacity will increase from 0 to 1:</p>
<pre class="brush:css">.cr-titles h3{
	position: absolute;
	width: 100%;
	text-align: center;
	top: 50%;
	z-index: 10000;
	opacity: 0;
	color: #fff;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
	transition: opacity 0.8s ease-in-out;
}
.cr-titles h3 span:nth-child(1){
	font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
	font-size: 70px;
	display: block;
	letter-spacing: 7px;
}
.cr-titles h3 span:nth-child(2){
	letter-spacing: 0px;
	display: block;
	background: rgba(104,171,194,0.9);
	font-size: 14px;
	padding: 10px;
	font-style: italic;
	font-family: Cambria, Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, serif;
}
.cr-container input.cr-selector-img-1:checked ~ .cr-titles h3:nth-child(1),
.cr-container input.cr-selector-img-2:checked ~ .cr-titles h3:nth-child(2),
.cr-container input.cr-selector-img-3:checked ~ .cr-titles h3:nth-child(3),
.cr-container input.cr-selector-img-4:checked ~ .cr-titles h3:nth-child(4){
	opacity: 1;
}</pre>
<p>If you don&#8217;t want to use the label trick on mobile devices you could, for example, use a media query:</p>
<pre class="brush:css">@media screen and (max-width: 768px) {
	.cr-container input{
		display: inline;
		width: 24%;
		margin-top: 350px;
		z-index: 1000;
		position: relative;
	}
	.cr-container label{
		display: none;
	}
}</pre>
<p>This is just a quick solution and it might be better to check, <a href="http://v4.thewatchmakerproject.com/blog/how-to-fix-the-broken-ipad-form-label-click-issue/">if the label trick is supported</a>.</p>
<p>And that&#8217;s it! There are many possibilities of animations that can be done here. Check out the demos to see more.</p>
<h3>Demos</h3>
<ol>
<li><strong><a href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/index.html">Demo 1: Slide to right</a></strong></li>
<li><strong><a href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/index2.html">Demo 2: Odd/even slide to left/right</a></strong></li>
<li><strong><a href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/index3.html">Demo 3: Odd/even slide up/down</a></strong></li>
<li><strong><a href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/index4.html">Demo 4: Scale up/down</a></strong></li>
</ol>
<p>And that&#8217;s it! I hope you enjoyed this tutorial and find it inspiring!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/CSS3SlidingImagePanels/CSS3SlidingImagePanels.zip">Download source</a></p>
<div class="googlead"></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2012/01/17/sliding-image-panels-with-css3/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Lateral On-Scroll Sliding with jQuery</title>
		<link>http://tympanus.net/codrops/2011/12/05/lateral-on-scroll-sliding-with-jquery/</link>
		<comments>http://tympanus.net/codrops/2011/12/05/lateral-on-scroll-sliding-with-jquery/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 12:02:34 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[circle]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[timeline]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=6750</guid>
		<description><![CDATA[After getting the request, we are going to show you how to create a "slide-in on scroll" effect. You've probably seen this cool effect on some websites, like on Nizo or in the portfolio section of brilliantly designed La Moulade. The main idea is to laterally slide in elements depending on the scroll position of the document. Dividing the page into a left and right side, we want to move the elements from "outside" of the page to the center when they are in the viewport. We will also add the option to move the elements in 3D space.]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/LateralOnScrollSliding/" target="_blank"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/12/LateralOnScrollSliding.jpg" alt="LateralOnScrollSliding" width="580" height="315" class="aligncenter size-full wp-image-6752" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/LateralOnScrollSliding/" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/LateralOnScrollSliding/LateralOnScrollSliding.zip">Download source</a></p>
<p>After getting the request, we are going to show you how to create a &#8220;slide-in on scroll&#8221; effect. You&#8217;ve probably seen this cool effect on some websites, like on <a href="http://nizoapp.com/">Nizo</a> or in the portfolio section of brilliantly designed <a href="http://lamoulade.com/#!/projects">La Moulade</a>. The main idea is to laterally slide in elements depending on the scroll position of the document. Dividing the page into a left and right side, we want to move the elements from &#8220;outside&#8221; of the page to the center when they are in the viewport. We will also add the option to move the elements in 3D space.</p>
<p>The theme of today&#8217;s tutorial is going to be a timeline where we will have some circular elements on one side and the descriptions on the other. We&#8217;ll be alternating the sides to create a random look.</p>
<p>So, let&#8217;s start!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure is going to consist of a main container and some rows that we&#8217;ll use to place the left and the right elements. The left and right elements will either contain a h2 heading, a circular link with a background image or a description in form of a h3 element with a link and a span:</p>
<pre class="brush:xml">
&lt;div id="ss-container" class="ss-container"&gt;
	&lt;div class="ss-row"&gt;
		&lt;div class="ss-left"&gt;
			&lt;h2 id="november"&gt;November&lt;/h2&gt;
		&lt;/div&gt;
		&lt;div class="ss-right"&gt;
			&lt;h2&gt;2011&lt;/h2&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="ss-row ss-medium"&gt;
		&lt;div class="ss-left"&gt;
			&lt;a href="#" class="ss-circle ss-circle-1"&gt;Some title&lt;/a&gt;
		&lt;/div&gt;
		&lt;div class="ss-right"&gt;
			&lt;h3&gt;
				&lt;span&gt;November 28, 2011&lt;/span&gt;
				&lt;a href="#"&gt;Some Title&lt;/a&gt;
			&lt;/h3&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;!-- more rows... --&gt;
&lt;/div&gt;
</pre>
<p>For the circles we&#8217;ll have three different sizes and we&#8217;ll indicate that but giving the respective row the class of &#8220;ss-small&#8221;, &#8220;ss-medium&#8221; or &#8220;ss-large&#8221;.<br />
Let&#8217;s look at the style.</p>
<h3>The CSS</h3>
<p>The container will occupy all the width and we&#8217;ll set the overflow to hidden because we don&#8217;t want a scrollbar to appear when we move the left and right elements out of if:</p>
<pre class="brush:css">
.ss-container{
    width: 100%;
    position: relative;
    text-align: left;
    float: left;
	overflow: hidden;
	padding-bottom: 500px;
}
</pre>
<p>To create the middle line throughout the container, we&#8217;ll use a pseudo element that we&#8217;ll position in the middle of the container:</p>
<pre class="brush:css">
.ss-container:before{
    position: absolute;
    width: 4px;
    background: rgba(17,17,22,0.8);
    top: 0px;
    left: 50%;
	margin-left: -2px;
    content: '';
    height: 100%;
}
</pre>
<p>The row will serve as a wrapper for the left and right elements:</p>
<pre class="brush:css">
.ss-row{
    width: 100%;
    clear: both;
    float: left;
    position: relative;
    padding: 30px 0;
}
</pre>
<p>The two lateral elements will occupy half of the width:</p>
<pre class="brush:css">
.ss-left, .ss-right{
    float: left;
    width: 48%;
    position: relative;
}
.ss-right{
    padding-left: 2%;
}
.ss-left{
    text-align: right;
    float: left;
    padding-right: 2%;
}
</pre>
<p>The headings will have the following style:</p>
<pre class="brush:css">
.ss-container h2{
    font-size: 40px;
    text-transform: uppercase;
    color: rgba(78,84,123,0.2);
	text-shadow: 0px 1px 1px #fff;
	padding: 20px 0px;
}
.ss-container h3{
    margin-top: 34px;
	padding: 10px 15px;
	background: rgba(26, 27, 33, 0.6);
	text-shadow: 1px 1px 1px rgba(26, 27, 33, 0.8)
}
</pre>
<p>To create a circle, we&#8217;ll set the border radius of the anchor to 50% and we&#8217;ll add some neat box shadow:</p>
<pre class="brush:css">
.ss-circle{
    border-radius: 50%;
    overflow: hidden;
    display: block;
    text-indent: -9000px;
    text-align: left;
    box-shadow:
		0px 2px 5px rgba(0,0,0,0.7) inset,
		0px 0px 0px 12px rgba(61,64,85,0.3);
	background-size: cover;
	background-color: #f0f0f0;
	background-repeat: no-repeat;
	background-position: center center;
}
</pre>
<p>We&#8217;ll have three different circle sizes and depending on which side we are we&#8217;ll make the circle float either left or right:</p>
<pre class="brush:css">
.ss-small .ss-circle{
	width: 100px;
	height: 100px;
}
.ss-medium .ss-circle{
	width: 200px;
	height: 200px;
}
.ss-large .ss-circle{
	width: 300px;
	height: 300px;
}
.ss-left .ss-circle{
    float: right;
    margin-right: 30%;
}
.ss-right .ss-circle{
    float: left;
    margin-left: 30%;
}
</pre>
<p>We&#8217;ll use the pseudo element :before and :after in order to create the line and the arrow that will point to the middle line. The width will be defined as a percentage so that it adjust to the screen size. We&#8217;ll also center it by setting the top to 50% and correct the position by setting the margin-top to -3px. Depending on where we are (left or right side) we want the position to be different:</p>
<pre class="brush:css">
.ss-circle-deco:before{
	width: 29%;
	height: 0px;
	border-bottom: 5px dotted #ddd;
	border-bottom: 5px dotted rgba(17, 17, 22, 0.3);
	box-shadow: 0px 1px 1px #fff;
	position: absolute;
	top: 50%;
	content: '';
	margin-top: -3px;
}
.ss-left .ss-circle-deco:before{
    right: 2%;
}
.ss-right .ss-circle-deco:before{
    left: 2%;
}
</pre>
<p>The little arrow will be created by the border style and depending on if it&#8217;s a child of the left or right side, we&#8217;ll set the according border and position:</p>
<pre class="brush:css">
.ss-circle-deco:after{
	width: 0px;
	height: 0px;
	border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
	content: '';
	position: absolute;
	top: 50%;
	margin-top: -10px;
}
.ss-left .ss-circle-deco:after{
	right: 0;
	border-right: 10px solid rgba(17,17,22,0.8);
}
.ss-right .ss-circle-deco:after{
	left: 0;
	border-left: 10px solid rgba(17,17,22,0.8);
}
</pre>
<p>Because of the different circle sizes, we&#8217;ll need to adjust the position of the headings on the other side. We want them to be at the height of the arrow, so we&#8217;ll set the margins differently (the one for ss-small is already set in the circle itself):</p>
<pre class="brush:css">
.ss-container .ss-medium h3{
	margin-top: 82px;
}
.ss-container .ss-large h3{
	margin-top: 133px;
}
.ss-container .ss-left h3{
	border-right: 5px solid rgba(164,166,181,0.8);
}
.ss-container .ss-right h3{
	border-left: 5px solid rgba(164,166,181,0.8);
}
</pre>
<p>The style for the description:</p>
<pre class="brush:css">
.ss-container h3 span{
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    display: block;
    padding-bottom: 5px;
}
.ss-container h3 a{
    font-size: 28px;
    color: rgba(255,255,255,0.9);
    display: block;
}
.ss-container h3 a:hover{
	color: rgba(255,255,255,1);
}
</pre>
<p>Each circle is going to have a different background image:</p>
<pre class="brush:css">
.ss-circle-1{
    background-image:url(../images/1.jpg);
}
.ss-circle-2{
    background-image: url(../images/2.jpg);
}
.ss-circle-3{
    background-image: url(../images/3.jpg);
}
/* and so on... */
</pre>
<p>And that&#8217;s all the style! Let&#8217;s take a look at the JavaScript.</p>
<h3>The JavaScript</h3>
<p>The main idea is to initially show all the side elements that are visible on the viewport. All the other elements will be hidden by setting their left or right value to -50%. If the perspective option is set to true, then these elements will be translated and rotated on the y-axis, with the opacity set to 0. On scroll, we want to show the lateral elements by sliding them to position 0 (left or right, respectively), or in case of perspective, translate / rotate them accordingly once they are in the viewport. </p>
<p>Let&#8217;s start by defining some variables:</p>
<pre class="brush:js">
	// the row elements
var $rows			= $('#ss-container > div.ss-row'),
	// we will cache the inviewport
	// rows and the outside viewport rows
	$rowsViewport, $rowsOutViewport,
	// navigation menu links
	$links			= $('#ss-links > a'),
	// the window element
	$win			= $(window),
	// we will store the window sizes here
	winSize			= {},
	// used in the scroll setTimeout function
	anim			= false,
	// page scroll speed
	scollPageSpeed	= 2000 ,
	// page scroll easing
	scollPageEasing = 'easeInOutExpo',
    // perspective?
    hasPerspective	= true,
    perspective	= hasPerspective &#038;&#038; Modernizr.csstransforms3d,
</pre>
<p>We&#8217;ll have the following functions:</p>
<pre class="brush:js">
// initialize function
init			= function() {
	// get window sizes
	getWinSize();
	// initialize events
	initEvents();
	// define the inviewport selector
	defineViewport();
	// gets the elements that match the previous selector
	setViewportRows();
	// if perspective add css
	if( perspective ) {
		$rows.css({
			'-webkit-perspective'		: 600,
			'-webkit-perspective-origin'	: '50% 0%'
		});
	}
	// show the pointers for the inviewport rows
	$rowsViewport.find('a.ss-circle').addClass('ss-circle-deco');
	// set positions for each row
	placeRows();
},
</pre>
<p><strong>defineViewport</strong> defines a selector that gathers the row elements that are initially visible. An element is visible if its top is less than the window&#8217;s height. These elements will not be affected when scrolling the page:</p>
<pre class="brush:js">
defineViewport	= function() {

	$.extend( $.expr[':'], {

		inviewport	: function ( el ) {
			if ( $(el).offset().top < winSize.height ) {
				return true;
			}
			return false;
		}

	});

},
</pre>
<p><strong>setViewportRows</strong> checks which rows are initially visible:</p>
<pre class="brush:js">
setViewportRows	= function() {

	$rowsViewport 		= $rows.filter(':inviewport');
	$rowsOutViewport	= $rows.not( $rowsViewport )

},
</pre>
<p><strong>getWinSize</strong> gets the window width and height:</p>
<pre class="brush:js">
getWinSize		= function() {

	winSize.width	= $win.width();
	winSize.height	= $win.height();

},
</pre>
<p>And now let's initialize some events:</p>
<pre class="brush:js">
	initEvents		= function() {

		// navigation menu links.
		// scroll to the respective section.
		$links.on( 'click.Scrolling', function( event ) {

			// scroll to the element that has id = menu's href
			$('html, body').stop().animate({
				scrollTop: $( $(this).attr('href') ).offset().top
			}, scollPageSpeed, scollPageEasing );

			return false;

		});

		$(window).on({
			// on window resize we need to redefine
			// which rows are initially visible
			// (this ones we will not animate).
			'resize.Scrolling' : function( event ) {

				// get the window sizes again
				getWinSize();
				// redefine which rows are initially
				// visible (:inviewport)
				setViewportRows();
				// remove pointers for every row
				$rows.find('a.ss-circle').removeClass('ss-circle-deco');
				// show inviewport rows and respective pointers
				$rowsViewport.each( function() {

					$(this).find('div.ss-left')
						   .css({ left   : '0%' })
						   .end()
						   .find('div.ss-right')
						   .css({ right  : '0%' })
						   .end()
						   .find('a.ss-circle')
						   .addClass('ss-circle-deco');

				});

			},
			// when scrolling the page change
			// the position of each row
			'scroll.Scrolling' : function( event ) {

				// set a timeout to avoid that the
				// placeRows function gets called on
				// every scroll trigger
				if( anim ) return false;
				anim = true;
				setTimeout( function() {

					placeRows();
					anim = false;

				}, 10 );

			}
		});

	},
</pre>
<p><strong>placeRows</strong> sets the position of the rows (left and right row elements). Both of these elements will start with -50% for the left/right (not visible). This value should be 0% (final position) when the element is in the center of the window.</p>
<pre class="brush:js">
placeRows		= function() {
		// how much we scrolled so far
	var winscroll	= $win.scrollTop(),
		// the y value for the center of the screen
	winCenter	= winSize.height / 2 + winscroll;

	// for every row that is not inviewport
	$rowsOutViewport.each( function(i) {

		var $row	= $(this),
			// the left side element
			$rowL	= $row.find('div.ss-left'),
			// the right side element
			$rowR	= $row.find('div.ss-right'),
			// top value
			rowT	= $row.offset().top;

		// hide the row if it is under the viewport
		if( rowT > winSize.height + winscroll ) {

			if( perspective ) {

				$rowL.css({
					'-webkit-transform'	: 'translate3d(-75%, 0, 0) rotateY(-90deg) translate3d(-75%, 0, 0)',
					'opacity'			: 0
				});
				$rowR.css({
					'-webkit-transform'	: 'translate3d(75%, 0, 0) rotateY(90deg) translate3d(75%, 0, 0)',
					'opacity'			: 0
				});

			}
			else {

				$rowL.css({ left 		: '-50%' });
				$rowR.css({ right 		: '-50%' });

			}

		}
		// if not, the row should become visible
		// (0% of left/right) as it gets closer to
		// the center of the screen.
		else {

				// row's height
			var rowH	= $row.height(),
				// the value on each scrolling step
				// will be proporcional to the distance
				// from the center of the screen to its height
				factor 	= ( ( ( rowT + rowH / 2 ) - winCenter ) / ( winSize.height / 2 + rowH / 2 ) ),
				// value for the left / right of each side of the row.
				// 0% is the limit
				val		= Math.max( factor * 50, 0 );

			if( val <= 0 ) {

				// when 0% is reached show the pointer for that row
				if( !$row.data('pointer') ) {

					$row.data( 'pointer', true );
					$row.find('.ss-circle').addClass('ss-circle-deco');

				}

			}
			else {

				// the pointer should not be shown
				if( $row.data('pointer') ) {

					$row.data( 'pointer', false );
					$row.find('.ss-circle').removeClass('ss-circle-deco');

				}

			}

			// set calculated values
			if( perspective ) {

				var	t = Math.max( factor * 75, 0 ),
					r = Math.max( factor * 90, 0 ),
					o = Math.min( Math.abs( factor - 1 ), 1 );

				$rowL.css({
					'-webkit-transform'	: 'translate3d(-' + t + '%, 0, 0) rotateY(-' + r + 'deg) translate3d(-' + t + '%, 0, 0)',
					'opacity'           : o
				});
				$rowR.css({
					'-webkit-transform'	: 'translate3d(' + t + '%, 0, 0) rotateY(' + r + 'deg) translate3d(' + t + '%, 0, 0)',
					'opacity'		: o
				});

			}
			else {

				$rowL.css({ left 	: - val + '%' });
				$rowR.css({ right 	: - val + '%' });

			}

		}	

	});

};

return { init : init };
</pre>
<h3>Demos</h3>
<p>Check out the two demos, one with the "normal" slide in and one with the 3D sliding:</p>
<ul>
<li><a href="http://tympanus.net/Tutorials/LateralOnScrollSliding/" target="_blank">Default demo</a></li>
<li><a href="http://tympanus.net/Tutorials/LateralOnScrollSliding/index2.html" target="_blank">Perspective Demo (Webkit only)</a></li>
</ul>
<p>And that's it! I hope you enjoyed this tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/LateralOnScrollSliding/" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/LateralOnScrollSliding/LateralOnScrollSliding.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/12/05/lateral-on-scroll-sliding-with-jquery/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
		<item>
		<title>Vertical Sliding Accordion with jQuery</title>
		<link>http://tympanus.net/codrops/2011/07/22/vertical-sliding-accordion/</link>
		<comments>http://tympanus.net/codrops/2011/07/22/vertical-sliding-accordion/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 12:36:52 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[vertical]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=5371</guid>
		<description><![CDATA[Today we want to share a slick and flexible vertical jQuery accordion with you. The main idea is to expand the accordion slices on click and show some more information. The other slices will become less opaque and squeezed. When navigating to the next slice using one navigation arrows, a new slice will slide in from the top or the bottom. Once a slice is open and we navigate, the subsequent slice will open on slide.]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Development/VerticalSlidingAccordion/example1.html" title="Vertical Sliding Accordion " target="_blank"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/07/verticalSlidingAccordion.jpg" alt="" title="verticalSlidingAccordion" width="580" height="315" class="aligncenter size-full wp-image-5374" /></a><br />
<a class="demo" href="http://tympanus.net/Development/VerticalSlidingAccordion/example1.html" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Development/VerticalSlidingAccordion/VerticalSlidingAccordion.zip">Download source</a></p>
<p>Today we want to share a slick and flexible vertical jQuery accordion with you. The main idea is to expand the accordion slices on click and show some more information. The other slices will become less opaque and squeezed. When navigating to the next slice using one navigation arrows, a new slice will slide in from the top or the bottom. Once a slice is open and we navigate, the subsequent slice will open on slide.</p>
<p>The beautiful portrait photography is by Images by Alan Turkus. Check out his <a href="http://www.flickr.com/photos/aturkus/" title="Flickr Photostream of Alan Turkus" target="_blank">Flickr Photostream</a>. The images are licensed under the <a href="http://creativecommons.org/licenses/by/2.0/" title="Creative Commons Attribution 2.0 Generic (CC BY 2.0)" target="_blank">Creative Commons Attribution 2.0 Generic (CC BY 2.0) License</a>.</p>
<p>We also use the <a href="http://brandonaaron.net/code/mousewheel/docs" title="jQuery Mousewheel Plugin Documentation" target="_blank">jQuery Mousewheel Plugin by Brandon Aaron</a> which allows us to navigate through the accordion using the mouse wheel. </p>
<p>The options for this plugin allow to customize the height and width, the number of slices visible, the height of an expanded slice and others. Let&#8217;s first see some examples before we explain each option.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>Examples</h3>
<p>Take a look at all the examples (you can also navigate from them to all the other demos):</p>
<ul>
<li><a target="_blank" href="http://tympanus.net/Development/VerticalSlidingAccordion/example1.html">3 visible slices / Default</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/VerticalSlidingAccordion/example2.html">With easing</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/VerticalSlidingAccordion/example3.html">5 visible Slices and higher transparency</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/VerticalSlidingAccordion/example4.html">2 visible slices and slower animation</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/VerticalSlidingAccordion/example5.html">Fullscreen example</a></li>
</ul>
<p>For the HTML structure we have the accordion container, the navigation spans and the wrapper with the slices:</p>
<pre class="brush:xml">
&lt;div id="va-accordion" class="va-container"&gt;
	&lt;div class="va-nav"&gt;
		&lt;span class="va-nav-prev"&gt;Previous&lt;/span&gt;
		&lt;span class="va-nav-next"&gt;Next&lt;/span&gt;
	&lt;/div&gt;
	&lt;div class="va-wrapper"&gt;
		&lt;div class="va-slice va-slice-1"&gt;
			&lt;h3 class="va-title"&gt;Marketing&lt;/h3&gt;
			&lt;div class="va-content"&gt;
				&lt;p&gt;Henry Watson&lt;/p&gt;
				&lt;ul&gt;
					&lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
			&lt;/div&gt;
		&lt;/div&gt;
		&lt;div class="va-slice va-slice-2"&gt;
			...
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>We give each slice a different class to define a background image for them. In the last fullscreen example we have color classes to assign a different background color to each slice.</p>
<p>Let&#8217;s take a look at the example with just 2 slices and a slower animation speed:</p>
<pre class="brush:js">
$('#va-accordion').vaccordion({
	expandedHeight	: 350,
	animSpeed		: 400,
	animOpacity		: 0.7,
	visibleSlices	: 2
});
</pre>
<p>The following options are available:</p>
<pre class="brush:js">
// the accordion's width
accordionW		: 1000,
// the accordion's height
accordionH		: 450,
// number of visible slices
visibleSlices	: 3,
// the height of a opened slice
// should not be more than accordionH
expandedHeight	: 350,
// speed when opening / closing a slice
animSpeed		: 250,
// easing when opening / closing a slice
animEasing		: 'jswing',
// opacity value for the collapsed slices
animOpacity		: 0.2,
// time to fade in the slice's content
contentAnimSpeed: 900,
// if this is set to false,
// we collapse any opened slice
// before sliding
savePositions	: true
</pre>
<p>If you, for example, would like to show a slice fully on expansion, using the whole height of the accordion container, then you set the expandedHeight to the same value like the accordionH (the height of the accordion). In our last example we used the full window width and height and also adjusted some style (see inline style in the example) in order to remove any margins: </p>
<pre class="brush:js">
$('#va-accordion').vaccordion({
	accordionW		: $(window).width(),
	accordionH		: $(window).height(),
	visibleSlices	: 5,
	expandedHeight	: 450,
	animOpacity		: 0.1,
	contentAnimSpeed: 100
});
</pre>
<p>We hope you like this accordion and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Development/VerticalSlidingAccordion/example1.html" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Development/VerticalSlidingAccordion/VerticalSlidingAccordion.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/07/22/vertical-sliding-accordion/feed/</wfw:commentRss>
		<slash:comments>88</slash:comments>
		</item>
		<item>
		<title>Sliding Background Image Menu with jQuery</title>
		<link>http://tympanus.net/codrops/2011/07/03/sliding-background-image-menu/</link>
		<comments>http://tympanus.net/codrops/2011/07/03/sliding-background-image-menu/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 17:36:34 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[background-image]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=4977</guid>
		<description><![CDATA[Today we want to share another jQuery menu with you. This menu will have several panels, each one corresponding to a different background image that will show on all panels when we hover over a panel label.  Also, a submenu will slide out from the bottom. This menu comes with some configuration possibilities, such as size of the image, the hover effect and custom default states.]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example5.html" target="_blank"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/07/SlidingBackgroundImageMenu.jpg" alt="" title="SlidingBackgroundImageMenu" width="580" height="315" class="aligncenter size-full wp-image-4978" /></a><br />
<a class="demo" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example5.html" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/SlidingBackgroundImageMenu.zip">Download source</a><br />
Today we want to share another jQuery menu with you. This menu will have several panels, each one corresponding to a different background image that will show on all panels when we hover over a panel label.  Also, a submenu will slide out from the bottom. This menu comes with some configuration possibilities, such as the size of the image, the hover effect and custom default states.</p>
<p>The idea of this navigation is based on the <a target="_blank" href="http://tympanus.net/codrops/2010/05/05/beautiful-background-image-navigation-with-jquery/">Beautiful Background Image Navigation with jQuery</a>, a tutorial that had a similar effect. Since it was very popular and a lot of our readers asked for some very useful additions, we decided to revamp it and make it easier to customize.</p>
<p>The beautiful gastronomy photography is by Manoel Petry:<br />
<a target="_blank" href="http://www.flickr.com/people/manoelpetry/">Manoel Petry&#8217;s Flickr Photostream</a><br />
<a target="_blank" href="http://www.manoelpetry.com/">Manoel Petry&#8217;s Website</a><br />
The images are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike 2.0 Generic License</a>.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>Examples</h3>
<p>Take a look at all the examples (you can also navigate from them to all the other demos):</p>
<ul>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example1.html">Show/hide</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example2.html">Fade</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example3.html">Sequential fade</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example4.html">Side slide</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example4_1.html">Side slide (bounce)</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example5.html">Sequential slide</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example6.html">Up/down</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example7.html">Sequential up/down</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example8.html">Alternating up/down</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example8_1.html">Alternating up/down (2)</a></li>
<li><a target="_blank" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example9.html">Sequential alternating up/down</a></li>
</ul>
<p>The HTML structure consists of the &#8220;sbi_container&#8221; which will have all the panels inside:</p>
<pre class="brush:xml">
&lt;div id="sbi_container" class="sbi_container"&gt;
	&lt;div class="sbi_panel" data-bg="images/1.jpg"&gt;
		&lt;a href="#" class="sbi_label"&gt;About&lt;/a&gt;
		&lt;div class="sbi_content"&gt;
			&lt;ul&gt;
				&lt;li&gt;&lt;a href="#"&gt;Subitem&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#"&gt;Subitem&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#"&gt;Subitem&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="sbi_panel" data-bg="images/2.jpg"&gt;
		...
	&lt;/div&gt;
	...
&lt;/div&gt;
</pre>
<p>The &#8220;data-bg&#8221; attribute contains the path to the background image that will appear when hovering over the label of the respective panel.</p>
<p>Let&#8217;s take a look at an example for using the alternating vertical up/down sliding effect:</p>
<pre class="brush:js">
$('#sbi_container').bgImageMenu({
	defaultBg	: 'images/default.jpg',
	menuSpeed	: 300,
	border		: 1,
	type		: {
		mode		: 'verticalSlideAlt',
		speed		: 450,
		easing		: 'easeOutBack'
	}
});
</pre>
<p>The following parameters can be used/set:<br />
<strong>defaultBg:</strong> the default image shown when no label is hovered<br />
<strong>pos:</strong> if no defaultBg set, pos will indicate the panel that should be shown/open<br />
<strong>width:</strong> the width of the container and the images (they should all be of the same size)<br />
<strong>height:</strong> the height of the container and the images<br />
<strong>border:</strong> the width of the margin between the panels<br />
<strong>menuSpeed:</strong> the speed with which the menu should slide up</p>
<p><strong>mode:</strong> the type of animation; you can use def | fade | seqFade | horizontalSlide | seqHorizontalSlide | verticalSlide | seqVerticalSlide | verticalSlideAlt | seqVerticalSlideAlt<br />
<strong>speed:</strong> the speed of the panel animation<br />
<strong>easing:</strong> the easing effect for the animation<br />
<strong>seqfactor:</strong> delay between each item animation for seqFade | seqHorizontalSlide | seqVerticalSlide | seqVerticalSlideAlt </p>
<p>We hope you find this little menu interesting and useful, enjoy!</p>
<p><a class="demo" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/example5.html" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Development/SlidingBackgroundImageMenu/SlidingBackgroundImageMenu.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/07/03/sliding-background-image-menu/feed/</wfw:commentRss>
		<slash:comments>90</slash:comments>
		</item>
		<item>
		<title>Sliding Letters with jQuery</title>
		<link>http://tympanus.net/codrops/2011/05/09/sliding-letters-with-jquery/</link>
		<comments>http://tympanus.net/codrops/2011/05/09/sliding-letters-with-jquery/#comments</comments>
		<pubDate>Mon, 09 May 2011 10:40:08 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[letters]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=4720</guid>
		<description><![CDATA[Today we have a neat little effect for you. We want to bring some life to the standard hover effect by playing around with the letters in an anchor word. The aim is to slide in letter by letter when hovering over a link element. We can either have the same word or a different [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://tympanus.net/Development/SlidingLetters/"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/05/slidingLetters.jpg" alt="" title="slidingLetters" width="580" height="315" class="aligncenter size-full wp-image-4721" /></a></p>
<p>Today we have a neat little effect for you. We want to bring some life to the standard hover effect by playing around with the letters in an anchor word. The aim is to slide in letter by letter when hovering over a link element. We can either have the same word or a different one and we can slide in the new letters all the same time or one after the other. </p>
<p>We will be using the <a target="_blank" href="http://letteringjs.com/">Lettering.js jQuery Plugin</a> which you can find on <a target="_blank" href="https://github.com/davatron5000/Lettering.js">Github</a>.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>Example</h3>
<p>In the following we will go through an example and we&#8217;ll start by the html for a little menu:</p>
<pre class="brush:xml">
&lt;div class="sl_examples"&gt;
	&lt;a href="#" id="example1" data-hover="Creativity"&gt;Illustrations&lt;/a&gt;
&lt;/div&gt;
</pre>
<p>We will use data-hover to indicate the word that should appear on hover. If you don&#8217;t use the data-hover then the same word will be used on hover.<br />
Then we will style it in the following way, making sure that we have the right properties for the structure that will be generated:</p>
<pre class="brush:css">
.sl_examples{
	float:left;
	font-family: 'Bevan', arial, serif;
	font-size:50px;
	line-height:50px;
	color:#f0f0f0;
	margin-right:5px;
	text-transform:uppercase;
}
.sl_examples a{
	display:block;
	position:relative;
	float:left;
	clear:both;
	color:#fff;
}
.sl_examples a > span{
	height:50px;
	float:left;
	position:relative;
	overflow:hidden;
}
.sl_examples a span span{
	position:absolute;
	display:block;
	left:0px;
	top:0px;
	text-align:center;
}
.sl_examples a span span.sl-w1{
	color:#fff;
	text-shadow:0px 0px 1px #fff;
	z-index:2;
}
.sl_examples a span span.sl-w2{
	color:#e82760;
	text-shadow:-1px 1px 2px #9f0633;
	z-index:3;
}
</pre>
<p>So, &#8220;sl-w1&#8243; is the class for the first word letters and &#8220;sl-w2&#8243; is the class for the second word letters.</p>
<p>Finally, we call the plugin:</p>
<pre class="brush:js">
$(window).load(function(){
	$('#example1').hoverwords({ delay:50 });
});
</pre>
<p>The following settings can be used:</p>
<pre class="brush:js">
delay		: false,		// each letter will have different animation times
speed		: 300,			// animation speed
easing		: 'jswing',		// easing animation
dir			: 'leftright', 	// leftright - current goes left, new one goes right || rightleft - current goes right, new one goes left,
overlay		: false,		// hover word is slided on top of the current word (just for the case when the hover word equals word)
opacity		: true			// animate the letters opacity
</pre>
<p>We hope you liked this little experiment and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Development/SlidingLetters/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Development/SlidingLetters/SlidingLetters.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/05/09/sliding-letters-with-jquery/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>Expanding Image Menu with jQuery</title>
		<link>http://tympanus.net/codrops/2011/03/16/expanding-image-menu/</link>
		<comments>http://tympanus.net/codrops/2011/03/16/expanding-image-menu/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 12:00:13 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[slide out]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=4469</guid>
		<description><![CDATA[View demoDownload source In today&#8217;s tutorial we will create an expanding image menu with jQuery. The idea is to have some columns with black and white image slices that will make a content area slide out when we click on them. We will also slide in the colored version of the image, creating a neat [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/03/expandingimagemenu.jpg" alt="" title="expandingimagemenu" width="580" height="315" class="aligncenter size-full wp-image-4481" /></a><br />
<a class="demo" href="http://tympanus.net/Tutorials/ExpandingImageMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ExpandingImageMenu/ExpandingImageMenu.zip">Download source</a></p>
<p>In today&#8217;s tutorial we will create an expanding image menu with jQuery. The idea is to have some columns with black and white image slices that will make a content area slide out when we click on them. We will also slide in the colored version of the image, creating a neat effect.</p>
<p>The photography is by talented <a href="http://www.flickr.com/people/robnas/" target="_blank">Robert Bejil</a>, check out his awesome photos on his <a target="_blank" href="http://www.flickr.com/photos/robnas/">Flickr photostream</a>.</p>
<p>So, let&#8217;s get started!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure consists of a main container and an unordered list where each item is one of the columns. We will give the main container the class &#8220;ei_menu&#8221; and also the id &#8220;ei_menu&#8221;. The list items are going to contain a link element with two spans inside and a div element with the content. The two spans are for the background image shown at the beginning and the colored version of the image for when we click on the item. Since we are using just one image for each we will have to define the background position. We will take care of that with the classes &#8220;pos1&#8243; to &#8220;pos5&#8243; that we will give to the parent link element.</p>
<pre class="brush:xml">
&lt;div id="ei_menu" class="ei_menu"&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href="#" class="pos1"&gt;
				&lt;span class="ei_preview"&gt;&lt;/span&gt;
				&lt;span class="ei_image"&gt;&lt;/span&gt;
			&lt;/a&gt;
			&lt;div class="ei_descr"&gt;
				&lt;h2&gt;Gary&lt;/h2&gt;
				&lt;h3&gt;Vocals&lt;/h3&gt;
				&lt;p&gt;Some text here...&lt;/p&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt; ... &lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>Let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>We are going to stretch the container for the list over the page and hide the overflow. Since we will adjust the size of the ul, we don&#8217;t want anything sticking out because of the slide out effect, to affect our container:</p>
<pre class="brush:css">
.ei_menu{
	background:#111;
	width:100%;
	overflow:hidden;
}
</pre>
<p>We will give enough width to the ul so that the li elements which will be floating, don&#8217;t wrap to the next &#8220;line&#8221; when they expand:</p>
<pre class="brush:css">
.ei_menu ul{
	height:350px;
	margin-left:50px;
	position:relative;
	display:block;
	width:1300px;
}
</pre>
<p>The overflow of the li elements is going to be hidden as well because our content inside is actually much bigger. And we only want to show that content, once we expand the while thing by increasing the width of the li:</p>
<pre class="brush:css">
.ei_menu ul li{
	float:left;
	width:75px;
	height:350px;
	position:relative;
	overflow:hidden;
	border-right:2px solid #111;
}
</pre>
<p>The &#8220;ei_preview&#8221; span will contain the black and white background image and will be of absolute positioning:</p>
<pre class="brush:css">
.ei_preview{
	width:75px;
	height:350px;
	cursor:pointer;
	position:absolute;
	top:0px;
	left:0px;
	background:transparent url(../images/bw.jpg) no-repeat top left;
}
</pre>
<p>The &#8220;ei_image&#8221; span will have the colored background image and be almost transparent. We will animate its position and also its opacity to create a cool effect:</p>
<pre class="brush:css">
.ei_image{
	position:absolute;
	left:75px;
	top:0px;
	width:75px;
	height:350px;
	opacity:0.2;
	background:transparent url(../images/color.jpg) no-repeat top left;
}
</pre>
<p>To define the positioning of the background for both spans, we will use the following classes, that we give to the parent link element:</p>
<pre class="brush:css">
.pos1 span{
	background-position:0px 0px;
}
.pos2 span{
	background-position:-75px 0px;
}
.pos3 span{
	background-position:-152px 0px;
}
.pos4 span{
	background-position:-227px 0px;
}
.pos5 span{
	background-position:-302px 0px;
}
.pos6 span{
	background-position:-377px 0px;
}
</pre>
<p>The content div will also have an absolute position and the left value is going to be the width of the spans:</p>
<pre class="brush:css">
.ei_descr{
	position:absolute;
	width:278px;
	height:310px;
	border-right:7px solid #f0f0f0;
	padding:20px;
	left:75px;
	top:0px;
	background:#fff;
}
</pre>
<p>We&#8217;ll spice up the heading of the content area with a nice grungy font that we&#8217;ll get from the Google fonts. We&#8217;ll also add some neat background stripes:</p>
<pre class="brush:css">
.ei_descr h2{
	font-family: 'Rock Salt', arial, serif;
	font-size:26px;
	color:#333;
	padding:10px;
	text-shadow:0px 0px 1px #fff;
	background:#fff url(../images/stripe_light.gif) repeat top left;
}
</pre>
<p>The sub heading will also have a font from the collection of Google fonts:</p>
<pre class="brush:css">
.ei_descr h3{
	font-family: 'Raleway', arial, serif;
	color:#fff;
	text-shadow:0px 0px 1px #000;
	font-style:normal;
	padding:10px;
	background:#333;
}
</pre>
<p>And finally, we style the paragraphs:</p>
<pre class="brush:css">
.ei_descr p{
	color:#000;
	padding:10px 5px 0px 5px;
	line-height:18px;
	font-size:11px;
	font-family: Arial, sans-serif;
	text-transform:uppercase;
}
</pre>
<p>And that&#8217;s all the style!<br />
Don&#8217;t forget to include the fonts that you are using from Google:</p>
<pre class="brush:xml">
&lt;link href='http://fonts.googleapis.com/css?family=Rock+Salt' rel='stylesheet' type='text/css' /&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Raleway:100' rel='stylesheet' type='text/css' /&gt;
</pre>
<p>This is added to the head of your HTML file.<br />
And now, let&#8217;s spice it up and add the magic!</p>
<h3>The JavaScript</h3>
<p>The main idea is to expand a menu item when clicking on it. This means that we want to animate the width of the li to 400 pixel (which is its initial width and the width of the spans, 75 pixel, plus the width of the content area which is 325 pixel counting with the padding and the border). While we do that, we also want to slide in the second span which has the colored background image and animate its opacity. We also want to decrease the opacity of the other items in order to enhance the current one. This will look as if they get darkened because we have a dark background.</p>
<p>Let&#8217;s begin by caching some elements:</p>
<pre class="brush:js">
var $menu				= $('#ei_menu > ul'),
	$menuItems			= $menu.children('li'),
	$menuItemsImgWrapper= $menuItems.children('a'),
	$menuItemsPreview	= $menuItemsImgWrapper.children('.ei_preview'),
	totalMenuItems		= $menuItems.length,
</pre>
<p>And let&#8217;s define the functionality:</p>
<pre class="brush:js">
ExpandingMenu 	= (function(){
	/*
		@current
		set it to the index of the element you want to be opened by default,
		or -1 if you want the menu to be closed initially
	 */
	var current				= -1,
	/*
		@anim
		if you want the default opened item to animate initially, set this to true
	 */
	anim				= true,
	/*
		checks if the current value is valid -
		between 0 and the number of items
	 */
	validCurrent		= function() {
		return (current &gt;= 0 &#038;&#038; current &lt; totalMenuItems);
	},
	init				= function() {
			/* show default item if current is set to a valid index */
		if(validCurrent())
			configureMenu();

		initEventsHandler();
	},
	configureMenu		= function() {
			/* get the item for the current */
		var $item	= $menuItems.eq(current);
			/* if anim is true, slide out the item */
		if(anim)
			slideOutItem($item, true, 900, 'easeInQuint');
		else{
				/* if not, just show it */
			$item.css({width : '400px'})
			.find('.ei_image')
			.css({left:'0px', opacity:1});

				/* decrease the opacity of the others */
				$menuItems.not($item)
						  .children('.ei_preview')
						  .css({opacity:0.2});
		}
	},
	initEventsHandler	= function() {
			/*
			when we click an item the following can happen:
			1) The item is already opened - close it!
			2) The item is closed - open it! (if another one is opened, close that one!)
			*/
		$menuItemsImgWrapper.bind('click.ExpandingMenu', function(e) {
			var $this 	= $(this).parent(),
			idx		= $this.index();

			if(current === idx) {
				slideOutItem($menuItems.eq(current), false, 1500, 'easeOutQuint', true);
				current = -1;
			}
			else{
				if(validCurrent() &#038;&#038; current !== idx)
						slideOutItem($menuItems.eq(current), false, 250, 'jswing');

				current	= idx;
					slideOutItem($this, true, 250, 'jswing');
			}
			return false;
		});
	},
		/* if you want to trigger the action to open a specific item */
		openItem			= function(idx) {
			$menuItemsImgWrapper.eq(idx).click();
		},
		/*
		opens or closes an item
		note that "mLeave" is just true when all the items close,
		in which case we want that all of them get opacity 1 again.
		"dir" tells us if we are opening or closing an item (true | false)
		*/
	slideOutItem		= function($item, dir, speed, easing, mLeave) {
		var $ei_image	= $item.find('.ei_image'),

		itemParam	= (dir) ? {width : '400px'} : {width : '75px'},
		imageParam	= (dir) ? {left : '0px'} : {left : '75px'};

			/*
			if opening, we animate the opacity of all the elements to 0.1.
			we do this in order to enhance the opened item more:
			*/
		if(dir)
		/*
				alternative:
				$menuItemsPreview.not($menuItemsPreview.eq(current))
								 .stop()
								 .animate({opacity:0.1}, 500);
		 */
			$menuItemsPreview.stop()
		.animate({opacity:0.1}, 1000);
		else if(mLeave)
			$menuItemsPreview.stop()
		.animate({opacity:1}, 1500);

			/* the &lt;li&gt; expands or collapses */
		$item.stop().animate(itemParam, speed, easing);
			/* the image span (color) slides in or out */
		$ei_image.stop().animate(imageParam, speed, easing, function() {
				/*
				if opening, we animate the opacity to 1,
				otherwise we reset it.
				*/
			if(dir)
				$ei_image.animate({opacity:1}, 2000);
			else
				$ei_image.css('opacity', 0.2);
		});
	};

	return {
		init 		: init,
		openItem	: openItem
	};
})();

/*
call the init method of ExpandingMenu
 */
ExpandingMenu.init();

/*
if you want to open / close a specific item you could do it like this:
ExpandingMenu.openItem(3); // toggles item 3 (zero-based indexing)
*/
</pre>
<p>And that&#8217;s all!</p>
<h3>Alternative Demos</h3>
<p>You can check out the following other demos which all make use of the different options in our script:</p>
<ul>
<li><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/index_1.html">One item opened already</a></li>
<li><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/index_2.html">One item will open (animate) on page load</a></li>
<li><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/index_3.html">Example of how to trigger the opening/closing the menu items</a></li>
</ul>
<p>All of these versions will be included in the ZIP file.<br />
We hope you enjoyed the tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/ExpandingImageMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ExpandingImageMenu/ExpandingImageMenu.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/03/16/expanding-image-menu/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Sweet Thumbnails Preview Gallery</title>
		<link>http://tympanus.net/codrops/2011/01/19/sweet-thumbnails-gallery/</link>
		<comments>http://tympanus.net/codrops/2011/01/19/sweet-thumbnails-gallery/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 17:12:57 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[image gallery]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=3719</guid>
		<description><![CDATA[View demoDownload source In this tutorial we will create an image gallery with jQuery that shows a preview of each image as a little thumbnail. The idea is to hover over the slider dots and make the regarding thumbnail slide into the previewer. When clicking a slider dot, the full image will slide in from [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/SweetThumbnails/" target="_blank"><img class="aligncenter size-full wp-image-3731" title="SweetThumbnailsPreviewGallery" src="http://tympanus.net/codrops/wp-content/uploads/2011/01/SweetThumbnailsPreviewGallery.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/SweetThumbnails/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/SweetThumbnails/SweetThumbnails.zip">Download source</a></p>
<p>In this tutorial we will create an image gallery with jQuery that shows a preview of each image as a little thumbnail. The idea is to hover over the slider dots and make the regarding thumbnail slide into the previewer. When clicking a slider dot, the full image will slide in from the right or left side, depending on the currently viewed image.</p>
<p><strong>Update:</strong> If you are interested in integrating the thumbnails preview slider you might want to check out the new post on how to use only the preview part:<br />
<a href="http://tympanus.net/codrops/2011/01/27/thumbnails-preview-slider/">Thumbnails Preview Slider with jQuery</a></p>
<p>The beautiful images are by talented <strong>geishaboy500</strong> and can be found here on his <a href="http://www.flickr.com/photos/geishaboy500/" target="_blank">Flickr Photostream</a>.</p>
<p>So, let&#8217;s roll!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure is going to consist of a main container which will have the image wrapper for the big image, the navigation items and the dot list with the thumbnail preview:</p>
<pre class="brush:xml">&lt;div id="ps_container" class="ps_container"&gt;
	&lt;div class="ps_image_wrapper"&gt;
		&lt;!-- First initial image --&gt;
		&lt;img src="images/1.jpg" alt="" /&gt;
	&lt;/div&gt;
	&lt;!-- Navigation items --&gt;
	&lt;div class="ps_next"&gt;&lt;/div&gt;
	&lt;div class="ps_prev"&gt;&lt;/div&gt;
	&lt;!-- Dot list with thumbnail preview --&gt;
	&lt;ul class="ps_nav"&gt;
		&lt;li class="selected"&gt;
			&lt;a href="images/1.jpg" rel="images/thumbs/1.jpg"&gt;Image 1&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href="images/2.jpg" rel="images/thumbs/2.jpg"&gt;Image 2&lt;/a&gt;
		&lt;/li&gt;
		...
		&lt;li class="ps_preview"&gt;
			&lt;div class="ps_preview_wrapper"&gt;
				&lt;!-- Thumbnail comes here --&gt;
			&lt;/div&gt;
			&lt;!-- Little triangle --&gt;
			&lt;span&gt;&lt;/span&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>The thumbnail preview element will be a list item in the dot list. It&#8217;s going to have a special class since we want to treat this element differently. Each dot list item will contain a link element which will hold the information on the thumbnail image and the big image. Using JavaScript, we will extract that path information from the attributes and create the image elements dynamically.</p>
<p>Let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>First, we will style the main container. Since our images have a maximum width of 680 pixel and a maximum height of 450 pixel, we will define the following values for the container (leaving some space for the dot list):</p>
<pre class="brush:css">.ps_container{
	display:none;
	width:680px;
	height:500px;
	margin:20px auto 0px auto;
	position:relative;
}
</pre>
<p>Now we will style the wrapper for the full images. Here we really set the exact maximum dimensions and say that the overflow is hidden. We do that because we want to be able to put two images inside of this wrapper but cut off the overflow. In our JS function we will animate the images so that the current one gets revealed.<br />
We will center the wrapper by setting the left and right margins to &#8220;auto&#8221;:</p>
<pre class="brush:css">.ps_image_wrapper{
	width:680px;
	height:450px;
	overflow:hidden;
	position:relative;
	margin:0 auto;
	-moz-box-shadow:0px 0px 5px #999;
	-webkit-box-shadow:0px 0px 5px #999;
	box-shadow:0px 0px 5px #999;
}
</pre>
<p>The image(s) inside of the wrapper should be of position absolute since we want to animate the left value to slide in the current image and slide out the previous one:</p>
<pre class="brush:css">.ps_image_wrapper img{
	position:absolute;
	left:0px;
	top:0px;
}
</pre>
<p>The navigation elements will have the following style:</p>
<pre class="brush:css">.ps_prev,
.ps_next{
	width:30px;
	height:59px;
	position:absolute;
	top:50%;
	margin-top:-40px;
	cursor:pointer;
	opacity:0.5;
}
.ps_prev{
	background:transparent url(../images/prev.png) no-repeat top center;
	left:-50px;
}
.ps_next{
	background:transparent url(../images/next.png) no-repeat top center;
	right:-50px;
}
.ps_prev:hover,
.ps_next:hover{
	opacity:0.9;
}
</pre>
<p>The dot list with the class &#8220;ps_nav&#8221; will be placed under the full image and centered by auto margins:</p>
<pre class="brush:css">ul.ps_nav{
	list-style:none;
	margin:0;
	padding:0;
	width:170px;
	margin:20px auto;
	position:relative;
}
</pre>
<p>The dot list elements will float:</p>
<pre class="brush:css">ul.ps_nav li{
	float:left;
}
</pre>
<p>And the inner link elements will get the dot background image, which is a sprites image:</p>
<pre class="brush:css">ul.ps_nav li a{
	display:block;
	text-indent:-9000px;
	width:11px;
	height:11px;
	outline:none;
	padding:0px 3px;
	background:transparent url(../images/dot.png) no-repeat top center;
}
</pre>
<p>On hover we will change the background position to show the other half:</p>
<pre class="brush:css">ul.ps_nav li a:hover,ul.ps_nav li.selected a{
	background-position:50% -11px;
}
</pre>
<p>Our special list element, the one that will have the thumbnail preview, will be of absolute positioning. The top has a negative value, since we want to pull this element up, beyond the list. The left value will be dynamically calculated. -34.5 pixel is the left value for the preview element when we want to show it over the first dot:</p>
<pre class="brush:css">ul.ps_nav li.ps_preview{
	display:none;
	width:85px;
	height:91px;
	top:-95px;
	left:-34.5px; /*This we will calculate dynamically*/
	position:absolute;
}
</pre>
<p>The span will be the little triangle:</p>
<pre class="brush:css">ul.ps_nav li.ps_preview span{
	background:transparent url(../images/triangle.png) no-repeat top center;
	width:15px;
	height:6px;
	position:absolute;
	top:85px;
	left:35px;
}
</pre>
<p>The preview wrapper will function the same way like the full image wrapper. We will hide the overflow:</p>
<pre class="brush:css">.ps_preview_wrapper{
	width:75px;
	height:75px;
	border:5px solid #fff;
	overflow:hidden;
	position:relative;
	-moz-box-shadow:0px 0px 5px #999;
	-webkit-box-shadow:0px 0px 5px #999;
	box-shadow:0px 0px 5px #999;
}
</pre>
<p>And ultimately, we want the thumbnails to be of absolute positioning since we want to animate the left value for the sliding effect:</p>
<pre class="brush:css">.ps_preview_wrapper img{
	position:absolute;
	top:0px;
	left:0px;
}
</pre>
<p>And that&#8217;s all the style. Let add the jQuery spice!</p>
<h3>The JavaScript</h3>
<p>The idea of this gallery is to show little thumbnails when hovering over a dot that represents and image.</p>
<p>When moving the cursor over the dots, we want to create a sliding animation that moves the next currently hovered thumbnail image into place. This will create a great effect, giving the illusion that we have an invisible bar of thumbnail images above the dots and our preview element makes them visible.</p>
<p>We also want the clicked image to show up by &#8220;pushing&#8221; the current one away, either from the left or from the right side.</p>
<p>Both effects we will achieve by placing the images or thumbs next to each other and animating their left value accordingly.</p>
<p>So, let&#8217;s begin by caching some elements:</p>
<pre class="brush:js">var $ps_container		= $('#ps_container'),
	$ps_image_wrapper 	= $ps_container.find('.ps_image_wrapper'),
	$ps_next			= $ps_container.find('.ps_next'),
	$ps_prev			= $ps_container.find('.ps_prev'),
	$ps_nav				= $ps_container.find('.ps_nav'),
	$tooltip			= $ps_container.find('.ps_preview'),
	$ps_preview_wrapper = $tooltip.find('.ps_preview_wrapper'),
	$links				= $ps_nav.children('li').not($tooltip),
	total_images		= $links.length,
	currentHovered		= -1,
	current				= 0,
	$loader				= $('#loader');
</pre>
<p>(The loader element was not mentioned in the HTML structure since we placed it outside of the container. We want to show a loading element until all the images are loaded. In the download file you will be able to see the preload function for the images.)</p>
<p>Now we need to check if the browser is a real one or, for whatever insane reason, a crappy one like, let&#8217;s say, IE:</p>
<pre class="brush:js">var ie 				= false;
if ($.browser.msie) {
	ie = true; // oh no sweet Jesus
}
if(!ie) // there is a God
	$tooltip.css({
		opacity	: 0
	}).show();
</pre>
<p>Basically, we want to give the preview element or tooltip the opacity 0 and animate it to 1 when we hover over it. Since in IE it does not help to simply add an opacity filter (elements inside are still shown) we want to use the show/hide instead of animating the opacity. So, we add display:none to the style of the class but take it out if we don&#8217;t use IE.</p>
<p>After preloading the images, we will show the container:</p>
<pre class="brush:js">/*first preload images (thumbs and large images)*/
var loaded	= 0;
$links.each(function(i){
	var $link 	= $(this);
	$link.find('a').preload({
		onComplete	: function(){
			++loaded;
			if(loaded == total_images){
				//all images preloaded,
				//show ps_container and initialize events
				$loader.hide();
				$ps_container.show();
				//when mouse enters the the dots,
				//show the tooltip,
				//when mouse leaves hide the tooltip,
				//clicking on one will display the respective image
				$links.bind('mouseenter',showTooltip)
					  .bind('mouseleave',hideTooltip)
					  .bind('click',showImage);
				//navigate through the images
				$ps_next.bind('click',nextImage);
				$ps_prev.bind('click',prevImage);
			}
		}
	});
});
</pre>
<p>The function <strong>showTooltip()</strong> will show the thumbnails preview and animate it to the right place. It will also slide the thumbnails inside, either to the right or to the left, depending where we are &#8220;coming from&#8221;:</p>
<pre class="brush:js">function showTooltip(){
	var $link			= $(this),
		idx				= $link.index(),
		linkOuterWidth	= $link.outerWidth(),
		//this holds the left value for the next position
		//of the tooltip
		left			= parseFloat(idx * linkOuterWidth) - $tooltip.width()/2 + linkOuterWidth/2,
		//the thumb image source
		$thumb			= $link.find('a').attr('rel'),
		imageLeft;

	//if we are not hovering the current one
	if(currentHovered != idx){
		//check if we will animate left-&gt;right or right-&gt;left
		if(currentHovered != -1){
			if(currentHovered &lt; idx){
				imageLeft	= 75;
			}
			else{
				imageLeft	= -75;
			}
		}
		currentHovered = idx;

		//the next thumb image to be shown in the tooltip
		var $newImage = $('<img alt="" />').css('left','0px')
								   .attr('src',$thumb);

		//if theres more than 1 image
		//(if we would move the mouse too fast it would probably happen)
		//then remove the oldest one (:last)
		if($ps_preview_wrapper.children().length &gt; 1)
			$ps_preview_wrapper.children(':last').remove();

		//prepend the new image
		$ps_preview_wrapper.prepend($newImage);

		var $tooltip_imgs		= $ps_preview_wrapper.children(),
			tooltip_imgs_count	= $tooltip_imgs.length;

		//if theres 2 images on the tooltip
		//animate the current one out, and the new one in
		if(tooltip_imgs_count &gt; 1){
			$tooltip_imgs.eq(tooltip_imgs_count-1)
						 .stop()
						 .animate({
							left:-imageLeft+'px'
						  },150,function(){
								//remove the old one
								$(this).remove();
						  });
			$tooltip_imgs.eq(0)
						 .css('left',imageLeft + 'px')
						 .stop()
						 .animate({
							left:'0px'
						  },150);
		}
	}
	//if we are not using a "browser", we just show the tooltip,
	//otherwise we fade it in
	//
	if(ie)
		$tooltip.css('left',left + 'px').show();
	else
	$tooltip.stop()
			.animate({
				left		: left + 'px',
				opacity		: 1
			},150);
}
</pre>
<p style="text-align: center;"><img class="nofancy size-full wp-image-3729  aligncenter" title="thumbnails" src="http://tympanus.net/codrops/wp-content/uploads/2011/01/thumbnails.jpg" alt="" width="478" height="236" /></p>
<p>The function <strong>hideTooltip()</strong> simply fades out the thumbnails preview (or hides it if IE):</p>
<pre class="brush:js">function hideTooltip(){
	//hide / fade out the tooltip
	if(ie)
		$tooltip.hide();
	else
	$tooltip.stop()
			.animate({
				opacity		: 0
			},150);
}
</pre>
<p>The following function will show an image in full size and animate the wrapper around to the right size. The new image will &#8220;slide into place&#8221;:</p>
<pre class="brush:js">function showImage(e){
	var $link				= $(this),
		idx					= $link.index(),
		$image				= $link.find('a').attr('href'),
		$currentImage 		= $ps_image_wrapper.find('img'),
		currentImageWidth	= $currentImage.width();

	//if we click the current one return
	if(current == idx) return false;

	//add class selected to the current page / dot
	$links.eq(current).removeClass('selected');
	$link.addClass('selected');

	//the new image element
	var $newImage = $('<img alt="" />').css('left',currentImageWidth + 'px')
							   .attr('src',$image);

	//if the wrapper has more than one image, remove oldest
	if($ps_image_wrapper.children().length &gt; 1)
		$ps_image_wrapper.children(':last').remove();

	//prepend the new image
	$ps_image_wrapper.prepend($newImage);

	//the new image width
	//this will be the new width of the ps_image_wrapper
	var newImageWidth	= $newImage.width();

	//check animation direction
	if(current &gt; idx){
		$newImage.css('left',-newImageWidth + 'px');
		currentImageWidth = -newImageWidth;
	}
	current = idx;
	//animate the new width of the ps_image_wrapper
	//(same like new image width)
	$ps_image_wrapper.stop().animate({
		width	: newImageWidth + 'px'
	},350);
	//animate the new image in
	$newImage.stop().animate({
		left	: '0px'
	},350);
	//animate the old image out
	$currentImage.stop().animate({
		left	: -currentImageWidth + 'px'
	},350);

	e.preventDefault();
}
</pre>
<p>The navigation functions will simply trigger a click event on the dots (which we already took care of in the beginning):</p>
<pre class="brush:js">function nextImage(){
	if(current &lt; total_images){ 		$links.eq(current+1).trigger('click'); 	} } function prevImage(){ 	if(current &gt; 0){
		$links.eq(current-1).trigger('click');
	}
}
</pre>
<p>And that&#8217;s all! We hope you enjoyed the sweet thumbnails tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/SweetThumbnails/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/SweetThumbnails/SweetThumbnails.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/01/19/sweet-thumbnails-gallery/feed/</wfw:commentRss>
		<slash:comments>128</slash:comments>
		</item>
		<item>
		<title>Pull Out Content Panel with jQuery</title>
		<link>http://tympanus.net/codrops/2010/11/01/pull-out-content-panel/</link>
		<comments>http://tympanus.net/codrops/2010/11/01/pull-out-content-panel/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 11:14:21 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[panel]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=3011</guid>
		<description><![CDATA[View demoDownload source In this tutorial we will create a content panel that slides out at a predefined scroll position. It will reveal a teaser with related content and it can be expanded to full page size to show more. A custom slider allows to scroll through many items in the panel. Depending on how [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/PullOutContentPanel/" target="_blank"><img class="aligncenter size-full wp-image-3016" title="PullOutContentPanel" src="http://tympanus.net/codrops/wp-content/uploads/2010/11/PullOutContentPanel.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/PullOutContentPanel/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/PullOutContentPanel/PullOutContentPanel.zip">Download source</a></p>
<p>In this tutorial we will create a content panel that slides out at a predefined scroll position. It will reveal a teaser with related content and it can be expanded to full page size to show more. A custom slider allows to scroll through many items in the panel.</p>
<p>Depending on how many items can fit to the user&#8217;s screen, we will adapt the item container in order make the maximum number of items fit, centering it horizontally.</p>
<p>Since we want to use a little slider for the scrolling, we will be working with the <a href="http://jqueryui.com/" target="_blank">jQuery UI library</a>.</p>
<p>So, let&#8217;s get started with the markup.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML will have following structure:</p>
<pre class="brush:xml">&lt;div class="pc_panel" id="pc_panel"&gt;
	&lt;div class="pc_label expand"&gt;&lt;/div&gt;
	&lt;div class="pc_label close"&gt;&lt;/div&gt;
	&lt;div class="pc_title"&gt;More on this topic&lt;/div&gt;
	&lt;div id="pc_wrapper"&gt;
		&lt;div id="pc_content"&gt;
			&lt;div class="pc_item"&gt;
				&lt;h2&gt;Annotation Overlay Effect with jQuery&lt;/h2&gt;
				&lt;img src="images/22.jpg" alt=""/&gt;
				&lt;p&gt;
					A slick overlay effect that let's
					you show notes on a portfolio item
				&lt;/p&gt;
				&lt;div class="pc_more"&gt;

http://tympanus.net/codrops/2010/10/12/annotation-overlay-effect/

				&lt;/div&gt;
			&lt;/div&gt;
			&lt;div class="pc_item"&gt;
				...
			&lt;/div&gt;
			...
			&lt;div class="clear"&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id="pc_slider" class="pc_slider"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>To add new item elements, we just need to repeat the structure of the div with the class &#8220;pc_item&#8221;.<br />
Because we will want to make the whole item clickable, we will add the link of the respective article into a div element with the class &#8220;pc_more&#8221;. </p>
<p>In our jQuery function we will then take care of that. Of course, you can simple add an href to a link element, but we want to show you how you can trigger links to open by reading them out from an element.</p>
<p>Let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>For the style, we will define the looks of the main panel and it&#8217;s content and we will also manipulate some classes of the jQuery UI elements.</p>
<p>Let&#8217;s start with the main panel:</p>
<pre class="brush:css">.pc_panel{
	position:fixed;
	background:transparent url(../images/bgSlide.png) repeat top left;
	color:#fff;
	font-size:11px;
	line-height:14px;
	width:100%;
	right:0px;
	display:none;
	font-family:Arial, Helvetica, sans-serif;
}
</pre>
<p>We will use fixed positioning for the panel since we want to make it follow us when we scroll the page. The panel will be initially invisible and when we scroll to the trigger position, we will slide it in from the right. </p>
<p>In our jQuery we will set its right value to minus the window width and then we will animate it to right:0px.</p>
<p>The little icons on the right for exanding/collapsing and for closing the teaser panel permanently will have the following style:</p>
<pre class="brush:css">.pc_label{
	width:20px;
	height:20px;
	position:absolute;
	top:0px;
	text-align:center;
	letter-spacing:2px;
	text-shadow:0px 0px 1px #fff;
	cursor:pointer;
}
.pc_panel .expand{
	background:#010101 url(../images/expand.gif) no-repeat center center;
	right:24px;
}
.pc_panel .collapse{
	background:#010101 url(../images/collapse.gif) no-repeat center center;
	right:24px;
}
.pc_panel .close{
	background:#010101 url(../images/close.gif) no-repeat center center;
	right:2px;
}
</pre>
<p>If you are using two classes on an element and you want the, let&#8217;s say, second class (in our case expand, collapse and close) to overwrite the properties of the first one, you need to make the definition for those classes more specific. That&#8217;s why we have our class &#8220;pc_label&#8221; and then we define the &#8220;stronger&#8221; classes by adding their parent (pc_panel).</p>
<p>The title for the panel will have the following style:</p>
<pre class="brush:css">.pc_title{
	width:100%;
	height:20px;
	background:#000;
	font-size:9px;
	text-transform:uppercase;
	line-height:20px;
	text-indent:10px;
	letter-spacing:1px;
}
</pre>
<p>Each item will have the following style:</p>
<pre class="brush:css">.pc_item{
	width:200px;
	height:120px;
	cursor:pointer;
	overflow:hidden;
	background:transparent url(../images/bgSlide.png) repeat top left;
	float:left;
	margin:5px 10px 10px 10px;
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
	-moz-box-shadow:0px 0px 5px #000;
	-webkit-box-shadow:0px 0px 5px #000;
	box-shadow:0px 0px 5px #000;
}
.pc_item h2{
	padding:10px 0px 10px 10px;
	font-size:14px;
	height:32px;
	color:#009ac6;
	line-height:11px;
	clear:both;
}
.pc_item p{
	text-align:justify;
	font-size:10px;
	text-shadow:1px 1px 1px #000;
	padding:0px 10px 5px 10px;
}
.pc_item img{
	width:50px;
	float:left;
	margin:0px 10px 0px 10px;
	border:4px solid #191919;
	-moz-box-shadow:0px 0px 5px #000;
	-webkit-box-shadow:0px 0px 5px #000;
	box-shadow:0px 0px 5px #000;
}
.pc_more{
	display:none;
}
</pre>
<p>When hovering over an item we will add the class &#8220;selected&#8221; to it, in order to make it look different:</p>
<pre class="brush:css">.pc_panel .selected{
	background:#222;
}
.pc_panel .selected img{
	border:4px solid #010101;
}
</pre>
<p>The wrapper around the items needs to have the following style because we want to apply the slider on the container:</p>
<pre class="brush:css">.pc_wrapper{
	overflow:hidden;
	position:relative;
	margin-top:10px;
}
</pre>
<p>The slider itself will have an absolute position:</p>
<pre class="brush:css">.pc_slider{
	position:absolute;
}
</pre>
<p>We want a customized look for the slider and the little slider handle, so we will overwrite the classes that come with jQuery UI:</p>
<pre class="brush:css">.ui-widget-content {
	background:#000;
}
.ui-state-default, .ui-widget-content .ui-state-default{
	border:none;
	background-color:#aaa;
	outline:none;
	cursor:pointer;
	height:17px;
	width:10px;
	left:0px;
	margin-bottom:-10px;
}
</pre>
<p>And, finally, a little helper class to clear the float in the end of the items so that we can work with the height of it&#8217;s container:</p>
<pre class="brush:css">.clear{
	clear:both;
}
</pre>
<p>And that&#8217;s all the style. Let&#8217;s look at the jQuery.</p>
<h3>The JavaScript</h3>
<p>The main idea is to make the panel appear at a certain position of the page. For that we will add a id=&#8221;pc_reference&#8221; to the last paragraph of our demo page because we want the panel to appear at the end of the page and show related items to the reader.</p>
<p>The shown panel will be of a specific height, revealing only the first row of related items/articles. When the user then expands the panel, it will occupy the full page and the user can use a scroll to see all items.</p>
<p>We want to have the possibility to expand the panel but also to remove it completely, since it could be annoying to the user (every time he scrolls past the specific trigger, it will appear).</p>
<p>Let&#8217;s first define some variables:</p>
<pre class="brush:js">//window width and height
var window_w 					= $(window).width();
var window_h 					= $(window).height();
//the main panel div
var $pc_panel = $('#pc_panel');
//the wrapper and the content divs
var $pc_wrapper					= $('#pc_wrapper');
var $pc_content					= $('#pc_content');
//the slider / slider div
var $pc_slider					= $('#pc_slider');
//the element reference - reaching this element
//activates the panel
var $pc_reference 				= $('#pc_reference');

var maxWidth,maxHeight,marginL;
</pre>
<p>Now, we will call the function <strong>buildPanel()</strong>, that already constructs the panel like it will look, when we expand it:</p>
<pre class="brush:js">buildPanel();

function buildPanel(){
	$pc_panel.css({'height': window_h + 'px'});
	hidePanel();
	//we want to display the items in a grid.
	//we need to calculate how much width and height
	//the wrapper should have.
	//we also want to display it centered, so we need to calculate
	//the margin left of the wrapper

	//First, lets see how much of height:
	//maxHeight = Math.floor((window_h-20)/135)*135;
	//20 =&gt; pc_titles height
	//135 =&gt; 125 of each items height plus its margin (10)
	maxHeight 		= Math.floor((window_h-20)/135)*135;
	//maxWidth = Math.floor((window_w-35)/220)*220;
	//220 = item width + margins (left and right)
	maxWidth 		= Math.floor((window_w-35)/220)*220;
	marginL  		= (window_w - maxWidth)/2;
	$pc_wrapper.css({
		'width' 		: maxWidth + 20 + 'px',
		'height'		: maxHeight +'px',
		'margin-left' 	: marginL + 'px'
	});

	//innitialize the slider
	try{
		$pc_slider.slider('destroy');
	}catch(e){}
	//total_scroll is the number of how much we can scroll
	var total_scroll = $pc_content.height()-maxHeight;
	//add a slider to scroll the content div
	//hidden until the panel is expanded
	if(total_scroll &gt; 0){
		$pc_slider.slider({
			orientation	: 'vertical',
			max			: total_scroll,
			min			: 0,
			value		: total_scroll,
			slide		: function(event, ui) {
				$pc_wrapper.scrollTop(Math.abs(ui.value-total_scroll));
			}
		}).css({
			'height'	: maxHeight -40 + 'px',//40 extra
			'left'		: maxWidth + 20 + marginL + 'px',
			'top'		: 30 + 20 + 'px',
			//30 = 20 of title + 10 margin, 20 extra
			'display'	: 'none'
		});
	}
}
</pre>
<p>Initially, we want to hide the panel outside of the viewport on the right side, so we define the following function:</p>
<pre class="brush:js">function hidePanel(){
	//165 =&gt; 20 pc_title + 120 item + margins
	$pc_panel.css({
		'right'	: -window_w + 'px',
		'top'	: window_h - 165 + 'px'
	}).show();
	try{
		//position the slider in the beginning
		slideTop();
	}catch(e){}
	$pc_slider.hide();
	$pc_panel.find('.collapse')
	.addClass('expand')
	.removeClass('collapse');
}
</pre>
<p>For our custom slider that will let us scroll through the items, we will define a function that resets it by sliding it all to the top:</p>
<pre class="brush:js">function slideTop(){
	var total_scroll 	= $pc_content.height()-maxHeight;
	$pc_wrapper.scrollTop(0);
	$pc_slider.slider('option', 'value', total_scroll );
}
</pre>
<p>Now, we want to define what happens when we reach the element that has the ID &#8220;pc_reference&#8221; while we scroll our page. We need to get the distance from the top to slide the panel out at the right position, and hide it, if we are more up than the trigger again:</p>
<pre class="brush:js">$(window).bind('scroll',function(){
	var distanceTop = $pc_reference.offset().top - window_h;
	if($(window).scrollTop() &gt; distanceTop){
		if(parseInt($pc_panel.css('right'),10) == -window_w)
			$pc_panel.stop().animate({'right':'0px'},300);
	}
	else{
		if(parseInt($pc_panel.css('right'),10) == 0)
			$pc_panel.stop().animate({'right': -window_w + 'px'},300,function(){
				hidePanel();
			});
	}
}).bind('resize',function(){
	//on resize calculate the windows dimentions again,
	//and build the panel accordingly
	window_w 			= $(window).width();
	window_h 			= $(window).height();
	buildPanel();
});
</pre>
<p>When we click on the expand button, we animate the panel to the size of the window and reset the custom slider and show it:</p>
<pre class="brush:js">$pc_panel.find('.expand').bind('click',function(){
	var $this = $(this);
	$pc_wrapper.hide();
	$pc_panel.stop().animate({'top':'0px'},500,function(){
		$pc_wrapper.show();
		slideTop();
		$pc_slider.show();
		$this.addClass('collapse').removeClass('expand');
	});
})
</pre>
<p>When we click on &#8220;collapse&#8221;, we will hide the slider and minimize the panel again:</p>
<pre class="brush:js">$pc_panel.find('.collapse').live('click',function(){
	var $this = $(this);
	$pc_wrapper.hide();
	$pc_slider.hide();
	$pc_panel.stop().animate({'top':window_h - 165 + 'px'},500,function(){
		$pc_wrapper.show();
		$this.addClass('expand').removeClass('collapse');
	});
});
</pre>
<p>Clicking &#8220;close&#8221; will make the panel disappear permanently:</p>
<pre class="brush:js">$pc_panel.find('.close').bind('click',function(){
	$pc_panel.remove();
	$(window).unbind('scroll').unbind('resize');
});
</pre>
<p>And finally, we want to add a hover effect to the items, and open a new window with the right location when the user clicks on it:</p>
<pre class="brush:js">$pc_wrapper.find('.pc_item').hover(
function(){
	$(this).addClass('selected');
},
function(){
	$(this).removeClass('selected');
}
).bind('click',function(){
	window.open($(this).find('.pc_more').html());
});
</pre>
<p>And that&#8217;s it! We hope you enjoyed the tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/PullOutContentPanel/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/PullOutContentPanel/PullOutContentPanel.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/11/01/pull-out-content-panel/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Polaroid Photobar Gallery with jQuery</title>
		<link>http://tympanus.net/codrops/2010/09/28/polaroid-photobar-gallery/</link>
		<comments>http://tympanus.net/codrops/2010/09/28/polaroid-photobar-gallery/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 11:54:55 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[image gallery]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2774</guid>
		<description><![CDATA[View demoDownload source In this tutorial we are going to create an image gallery with a Polaroid look. We will have albums that will expand to sets of slightly rotated thumbnails that pop out on hover. The full image will slide in from the bottom once a thumbnail is clicked. In the full image view [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/PolaroidPhotobarGallery/" target="_blank"><img class="aligncenter size-full wp-image-2786" title="polaroidphotobar" src="http://tympanus.net/codrops/wp-content/uploads/2010/09/polaroidphotobar.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/PolaroidPhotobarGallery/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/PolaroidPhotobarGallery/PolaroidPhotobarGallery.zip">Download source</a></p>
<p>In this tutorial we are going to create an image gallery with a Polaroid look. We will have albums that will expand to sets of slightly rotated thumbnails that pop out on hover. The full image will slide in from the bottom once a thumbnail is clicked. In the full image view the user can navigate through the pictures or simply choose another thumbnail to be displayed.</p>
<p>For this gallery we will be using the <a href="http://plugins.jquery.com/project/2d-transform" target="_blank">2D Transform plugin</a> to animate rotations.</p>
<p>The beautiful photos used in the demo are by talented <a href="http://www.flickr.com/photos/tetsumo/" target="_blank">Tetsumo</a>. Visit his blog <a href="http://www.yluux.com/" target="_blank">here</a>.</p>
<p>Let&#8217;s get started!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>We are going to include all our HTML in a div with the class &#8220;pp_gallery&#8221;. It will consist of the loading div, the navigation that will appear when the full image is viewed and the main thumbnails container.</p>
<p>Inside of the thumbnails container which will have the class &#8220;pp_thumbContainer&#8221;, we will have several divs for the albums and a div for going back to the album view. Each album will contain the thumbnails with a description wrapped in a div with the class &#8220;content&#8221;. We will also include a div element for the description of the album itself.</p>
<pre class="brush:xml">&lt;div id="pp_gallery" class="pp_gallery"&gt;
	&lt;div id="pp_loading" class="pp_loading"&gt;&lt;/div&gt;
	&lt;div id="pp_next" class="pp_next"&gt;&lt;/div&gt;
	&lt;div id="pp_prev" class="pp_prev"&gt;&lt;/div&gt;
	&lt;div id="pp_thumbContainer"&gt;
		&lt;div class="album"&gt;
			&lt;div class="content"&gt;
				&lt;img src="images/album1/thumbs/1.jpg" alt="images/album1/1.jpg" /&gt;
				&lt;span&gt;The Sixties by Tetsumo&lt;/span&gt;
			&lt;/div&gt;
			&lt;div class="content"&gt;
				&lt;img src="images/album1/thumbs/2.jpg" alt="images/album1/2.jpg" /&gt;
				&lt;span&gt;The Sixties by Tetsumo&lt;/span&gt;
			&lt;/div&gt;
			...
			&lt;div class="descr"&gt;
				The Sixties
			&lt;/div&gt;
		&lt;/div&gt;
		&lt;div class="album" style="bottom:-90px;"&gt;
			...
		&lt;/div&gt;
		...
		&lt;div class="pp_back"&gt;Albums&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The HTML structure of the dynamically created full image preview will be the following:</p>
<pre class="brush:xml">&lt;div id="pp_preview" class="pp_preview"&gt;
	&lt;img src="images/album1/1.jpg" /&gt;
	&lt;div class="pp_descr"&gt;&lt;span&gt;Description&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<p>Now, let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>We will start with a reset and some general styles for the body:</p>
<pre class="brush:css">*{
	margin:0;
	padding:0;
}
body{
	background:#000 url(../bg.jpg) repeat center center;
	font-family:"Myriad Pro", "Trebuchet MS", Helvetica, sans-serif;
	font-size:12px;
	color: #fff;
	overflow:hidden;
}</pre>
<p>A structured background fits very nicely, so we choose to add a wood texture. You can find this and more textures on <a href="http://webtreats.mysitemyway.com/greyscale-natural-grunge-textures/" target="_blank">Webtreats</a>.</p>
<p>Next, we will style the loading div and the navigation for stepping through the pictures when we are in the preview mode:</p>
<pre class="brush:css">.pp_loading{
	display:none;
	position:fixed;
	top:50%;
	left:50%;
	margin:-35px 0px 0px -35px;
	background:#fff url(../icons/loader.gif) no-repeat center center;
	width:70px;
	height:70px;
	z-index:999;
	opacity:0.7;
	-moz-border-radius:10px;
	-webkit-border-radius:10px;
	border-radius:10px;
}
.pp_next, .pp_prev{
	cursor:pointer;
	top:50%;
	margin-top:-16px;
	width:32px;
	height:32px;
	position:fixed;
	text-align:center;
	border:1px solid #111;
	color:#fff;
	-moz-box-shadow:0px 0px 3px #000;
	-webkit-box-shadow:0px 0px 3px #000;
	box-shadow:0px 0px 3px #000;
}
.pp_next{
	right:-40px;
	background:#222 url(../icons/next.png) no-repeat center center;
}
.pp_prev{
	left:-40px;
	background:#222 url(../icons/prev.png) no-repeat center center;
}</pre>
<p>The loading div is set to the center of the page by using the 50% negative margin trick. When the position is fixed, we can set the top and left to 50% and add a top and left margin to the negative value of half of the element&#8217;s width, or height, respectively.</p>
<p>The same we do for the navigation items, just that here will only center the elements vertically.</p>
<p>The thumbnails container will be positioned at the bottom of the page:</p>
<pre class="brush:css">#pp_thumbContainer{
	position:fixed;
	bottom:0px;
	left:0px;
	height:65px;
	width:100%;
}</pre>
<p>The albums are hidden initially. When we load the page, they will slide in from the bottom, so we will set the initial bottom value to -90 pixels:</p>
<pre class="brush:css">#pp_thumbContainer .album{
	position:absolute;
	width:200px;
	height:65px;
	bottom:-90px;
}</pre>
<p>The left value for the positioning of the albums will be calculated dynamically on page load. We will spread all the albums evenly throughout the width of the page.</p>
<p>The description of the album and the back element will share some styles:</p>
<pre class="brush:css">.album .descr,
.pp_back{
	position:absolute;
	bottom:0px;
	left:-16px;
	background:#222;
	text-align:center;
	border:1px solid #111;
	padding:5px;
	cursor:pointer;
	width:169px;
	color:#fff;
	cursor:pointer;
	text-shadow:0px 0px 1px #fff;
	-moz-box-shadow:1px 1px 4px #000;
	-webkit-box-shadow:1px 1px 4px #000;
	box-shadow:1px 1px 4px #000;
}</pre>
<p>&#8230;but not all. We will overwrite and add the values that are specific to the .pp_back class:</p>
<pre class="brush:css">.pp_back{
	text-transform:uppercase;
	bottom:120px;
	left:-100px;
	width:80px;
}</pre>
<p>The wrapper for the image and the image title will have the following style:</p>
<pre class="brush:css">#pp_thumbContainer .content{
	position:absolute;
	top:0px;
	height:155px;
	cursor:pointer;
}</pre>
<p>These wrappers will also be spread into position dynamically in our JavaScript. We set the top value to 0, so that all the thumbnails align to the top of the thumbnails container. We don&#8217;t want vertical thumbnails to stick out.</p>
<p>The thumbnail will have a white border and a box shadow:</p>
<pre class="brush:css">#pp_thumbContainer img{
	border:5px solid #fff;
	-moz-box-shadow:1px 1px 7px #000;
	-webkit-box-shadow:1px 1px 7px #000;
	box-shadow:1px 1px 7px #000;
}</pre>
<p>The description for each image is invisible. We will only use it to fill the description element for the full view.</p>
<pre class="brush:css">#pp_thumbContainer .content span{
	display:none;
}</pre>
<p>The wrapper for the full image will be positioned outside of the page by setting the top value to 150%. Once the image is loaded, we will slide it in from the bottom. We are setting the left value to 50% since we want to center the picture. Since we don&#8217;t know the width and height of the picture yet, we cannot set any negative margins yet. We will do that in our JavaScript function.</p>
<pre class="brush:css">.pp_preview{
	position:fixed;
	top:150%;
	left:50%;
}</pre>
<p>The full image will have a bigger white border at its bottom where we will insert the description:</p>
<pre class="brush:css">.pp_preview img{
	position:absolute;
	top:0px;
	left:0px;
	border:10px solid #fff;
	border-bottom:45px solid #fff;
	-moz-box-shadow:1px 1px 7px #000;
	-webkit-box-shadow:1px 1px 7px #000;
	box-shadow:1px 1px 7px #000;
}</pre>
<p>The description will be at the bottom of the preview element. In the JavaScript we will set the width and height of the preview div to the one of the image dynamically, so the description will be positioned at the thicker bottom border of the image.</p>
<pre class="brush:css">.pp_descr{
	height:45px;
	line-height:45px;
	font-size:20px;
	width:100%;
	bottom:0px;
	left:0px;
	position:absolute;
	text-align:center;
	color:#00021c;
}</pre>
<p>We will cufonize the description using a nice hand written font (see at the end).</p>
<p>And now, let&#8217;s add some real magic!</p>
<h3>The JavaScript</h3>
<p>There will be many animations throughout the JavaScript. The albums will slide in from the bottom when the page loads. Once an album is clicked, we will spread the thumbnails evenly by giving them an according left value. When we choose a thumbnail, we need to create the preview div and slide it in from the bottom. The image will get resized so that it fits into the window.</p>
<p>Let&#8217;s start by defining some initial variables. First, we want to know if we are dealing with Internet Explorer since we don&#8217;t want to use the rotation of the full image here (it&#8217;s buggy when used together with the slide in animation):</p>
<pre class="brush:js">var ie 			= false;
if ($.browser.msie) {
	ie = true;
}</pre>
<p>We will use some index variables for the navigation and save some elements:</p>
<pre class="brush:js">//current album/image displayed
var current		= -1;
var album		= -1;
//windows width
var w_width 	= $(window).width();
//caching
var $albums 	= $('#pp_thumbContainer div.album');
var $loader		= $('#pp_loading');
var $next		= $('#pp_next');
var $prev		= $('#pp_prev');
var $images		= $('#pp_thumbContainer div.content img');
var $back		= $('#pp_back');</pre>
<p>We want to spread the albums evenly throughout the page, so we will calculate the according left value:</p>
<pre class="brush:js">var nmb_albums	= $albums.length;
var spaces 		= w_width/(nmb_albums+1);
var cnt			= 0;
//preload all the images (thumbs)
var nmb_images	= $images.length;
var loaded  	= 0;
$images.each(function(i){
	var $image = $(this);
	$('&lt;img /&gt;').load(function(){
		++loaded;
		if(loaded == nmb_images){
			//let's spread the albums evenly at the bottom of the page
			$albums.each(function(){
				var $this 	= $(this);
				++cnt;
				var left	= spaces*cnt - $this.width()/2;
				$this.css('left',left+'px');
				$this.stop().animate({'bottom':'0px'},500);
			}).unbind('click').bind('click',spreadPictures);
			//also rotate each picture of an album with a random number of degrees
			$images.each(function(){
				var $this = $(this);
				var r = Math.floor(Math.random()*41)-20;
				$this.transform({'rotate'	: r + 'deg'});
			});
		}
	}).attr('src', $image.attr('src'));
});</pre>
<p>The <strong>spreadPictures</strong> function will do a similar thing: it will move the chosen album to the left and spread all the thumbnails:</p>
<pre class="brush:js">function spreadPictures(){
	var $album = $(this);
	//track which album is opened
	album = $album.index();
	//hide all the other albums
	$albums.not($album).stop().animate({'bottom':'-90px'},300);
		$album.unbind('click');
		//now move the current album to the left
		//and at the same time spread its images throughout
		//the window, rotating them randomly, hide the description of the album

	//store the current left for the reverse operation
	$album.data('left',$album.css('left'))
		  .stop()
		  .animate({'left':'0px'},500)
		  .find('.descr')
		  .stop()
		  .animate({'bottom':'-30px'},200);
		var total_pic 	= $album.find('.content').length;
		var cnt			= 0;
		//each picture
		$album.find('.content')
			  .each(function(){
			var $content = $(this);
			++cnt;
			//window width
			var w_width 	= $(window).width();
			var spaces 		= w_width/(total_pic+1);
			var left		= (spaces*cnt) - (140/2);
			var r 			= Math.floor(Math.random()*41)-20;
			//var r = Math.floor(Math.random()*81)-40;
		$content.stop().animate({'left':left+'px'},500,function(){
			$(this).unbind('click')
					   .bind('click',showImage)
					   .unbind('mouseenter')
					   .bind('mouseenter',upImage)
					   .unbind('mouseleave')
					   .bind('mouseleave',downImage);
		}).find('img')
		  .stop()
		  .animate({'rotate': r+'deg'},300);
		$back.stop().animate({'left':'0px'},300);
			});
}</pre>
<p>Now, we will define what happens when we click on the item to go back to the albums view. We will animate the album to its initial left position and slide the other albums up again. If the user was viewing a full image, we will make it slide up, out of the window (hideCurrentPicture):</p>
<pre class="brush:js">$back.bind('click',function(){
	$back.stop().animate({'left':'-100px'},300);
	hideNavigation();
	//there's a picture being displayed
	//lets slide the current one up
	if(current != -1){
		hideCurrentPicture();
	}

	var $current_album = $('#pp_thumbContainer div.album:nth-child('+parseInt(album+1)+')');
	$current_album.stop()
				  .animate({'left':$current_album.data('left')},500)
				  .find('.descr')
				  .stop()
				  .animate({'bottom':'0px'},500);

	$current_album.unbind('click')
				  .bind('click',spreadPictures);

	$current_album.find('.content')
			  .each(function(){
				var $content = $(this);
				$content.unbind('mouseenter mouseleave click');
				$content.stop().animate({'left':'0px'},500);
		});

	$albums.not($current_album).stop().animate({'bottom':'0px'},500);
	});</pre>
<p>The next function, called <strong>showImage</strong>, will display the full image by sliding it in from the bottom. If there was another image being shown, we will slide that one up. For centering the preview, we need to set its negative margins according to the width and height of the image. We will also rotate the preview randomly:</p>
<pre class="brush:js">function showImage(nav){
	if(nav == 1){
		//reached the first one
		if(current==0){
			return;
		}
		var $content = $('#pp_thumbContainer div.album:nth-child('+parseInt(album+1)+')')
					   .find('.content:nth-child('+parseInt(current)+')');
		//reached the last one
		if($content.length==0){
			current-=2;
			return;
		}
	}
	else
	var $content 	= $(this);

	//show ajax loading image
	$loader.show();

	//there's a picture being displayed
	//lets slide the current one up
	if(current != -1){
		hideCurrentPicture();
	}

	current 				= $content.index();
	var $thumb				= $content.find('img');
	var imgL_source 	 	= $thumb.attr('alt');
	var imgL_description 	= $thumb.next().html();
	//preload the large image to show
	$('&lt;img style=""/&gt;').load(function(){
		var $imgL 	= $(this);
		//resize the image based on the windows size
		resize($imgL);
		//create an element to include the large image
		//and its description
		var $preview = $('&lt;div /&gt;',{
			'id'		: 'pp_preview',
			'className'	: 'pp_preview',
			'html'     	: '&lt;div class="pp_descr"&gt;&lt;span&gt;'+imgL_description+'&lt;/span&gt;&lt;/div&gt;',
			'style'		: 'visibility:hidden;'
	});
		$preview.prepend($imgL);
		$('#pp_gallery').prepend($preview);
		var largeW 	= $imgL.width()+20;
		var largeH 	= $imgL.height()+10+45;
		//change the properties of the wrapping div
		//to fit the large image sizes
		$preview.css({
			'width'			:largeW+'px',
			'height'		:largeH+'px',
			'marginTop'		:-largeH/2-20+'px',
			'marginLeft'	:-largeW/2+'px',
			'visibility'	:'visible'
		});
		Cufon.replace('.pp_descr');
		//show navigation
		showNavigation();

		//hide the ajax image loading
		$loader.hide();

		//slide up (also rotating) the large image
		var r 			= Math.floor(Math.random()*41)-20;
		if(ie)
			var param = {
				'top':'50%'
			};
		else
			var param = {
				'top':'50%',
				'rotate': r+'deg'
			};
		$preview.stop().animate(param,500);
	}).error(function(){
		//error loading image.
		//Maybe show a message : 'no preview available'
	}).attr('src',imgL_source);
}</pre>
<p>The next two functions handle the navigation through the images:</p>
<pre class="brush:js">//click next image
$next.bind('click',function(){
	current+=2;
	showImage(1);
});

//click previous image
$prev.bind('click',function(){
	showImage(1);
});</pre>
<p>The function <strong>hideCurrentPicture</strong> will make the preview slide up. We will not use any rotation animation if the browser is IE:</p>
<pre class="brush:js">//slides up the current picture
function hideCurrentPicture(){
	current = -1;
	var r 	= Math.floor(Math.random()*41)-20;
	if(ie)
		var param = {
			'top':'-100%'
		};
	else
		var param = {
			'top':'-100%',
			'rotate': r+'deg'
		};
	$('#pp_preview').stop()
					.animate(param,500,function(){
						$(this).remove();
					});
}</pre>
<p>The <strong>showNavigation</strong> and <strong>hideNavigation</strong> functions will take care of showing and hiding the navigation items:</p>
<pre class="brush:js">//shows the navigation buttons
function showNavigation(){
	$next.stop().animate({'right':'0px'},100);
	$prev.stop().animate({'left':'0px'},100);
}

//hides the navigation buttons
function hideNavigation(){
	$next.stop().animate({'right':'-40px'},300);
	$prev.stop().animate({'left':'-40px'},300);
}</pre>
<p>When hovering over a thumbnail, we want it to move up a little and rotate slightly:</p>
<pre class="brush:js">function upImage(){
	var $content 	= $(this);
	$content.stop().animate({
		'marginTop'		: '-70px'
	},400).find('img')
		  .stop()
		  .animate({'rotate': '0deg'},400);
}</pre>
<p>When the mouse leaves the currently hovered thumbnail, we want it to drop back, rotating randomly again:</p>
<pre class="brush:js">function downImage(){
	var $content 	= $(this);
	var r 			= Math.floor(Math.random()*41)-20;
	$content.stop().animate({
		'marginTop'		: '0px'
	},400).find('img').stop().animate({'rotate': r + 'deg'},400);
}</pre>
<p>And finally, we will use a resize function to fit the full image into the window:</p>
<pre class="brush:js">function resize($image){
	var widthMargin		= 50
	var heightMargin 	= 200;

	var windowH      = $(window).height()-heightMargin;
	var windowW      = $(window).width()-widthMargin;
	var theImage     = new Image();
	theImage.src     = $image.attr("src");
	var imgwidth     = theImage.width;
	var imgheight    = theImage.height;

	if((imgwidth &gt; windowW)||(imgheight &gt; windowH)){
		if(imgwidth &gt; imgheight){
			var newwidth = windowW;
			var ratio = imgwidth / windowW;
			var newheight = imgheight / ratio;
			theImage.height = newheight;
			theImage.width= newwidth;
			if(newheight&gt;windowH){
				var newnewheight = windowH;
				var newratio = newheight/windowH;
				var newnewwidth =newwidth/newratio;
				theImage.width = newnewwidth;
				theImage.height= newnewheight;
			}
		}
		else{
			var newheight = windowH;
			var ratio = imgheight / windowH;
			var newwidth = imgwidth / ratio;
			theImage.height = newheight;
			theImage.width= newwidth;
			if(newwidth&gt;windowW){
				var newnewwidth = windowW;
				var newratio = newwidth/windowW;
				var newnewheight =newheight/newratio;
				theImage.height = newnewheight;
				theImage.width= newnewwidth;
			}
		}
	}
	$image.css({'width':theImage.width+'px','height':theImage.height+'px'});
}</pre>
<p>Since we cufonize the description, we need to add the following lines to the head of the HTML:</p>
<pre class="brush:xml">&lt;script src="js/cufon-yui.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="js/Note_this_400.font.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>You can find the beautiful &#8220;Note This&#8221; font on <a href="http://www.fontsquirrel.com/fonts/Note-this" target="_blank">www.fontsquirrel.com</a>.</p>
<p>And that&#8217;s it! We hope you enjoyed this tutorial and find it useful!!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/PolaroidPhotobarGallery/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/PolaroidPhotobarGallery/PolaroidPhotobarGallery.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
<div class="partner_section_post"><span>Message from Testking</span>Enjoy the free  learning  of web design with <a href="http://www.testkingsite.com/cisco/646-364.html">testking 646-364</a> tutorials.  Download <a href="http://www.testkingsite.com/exin/EX0-101.html">testking EX0-101</a> design tutorials and <a href="http://www.testkingsite.com/cisco/642-374.html">testking 642-374</a> study guides to become expert in web designing .</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/09/28/polaroid-photobar-gallery/feed/</wfw:commentRss>
		<slash:comments>111</slash:comments>
		</item>
		<item>
		<title>Collapsing Site Navigation with jQuery</title>
		<link>http://tympanus.net/codrops/2010/09/06/collapsing-site-navigation/</link>
		<comments>http://tympanus.net/codrops/2010/09/06/collapsing-site-navigation/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 15:58:26 +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[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2717</guid>
		<description><![CDATA[View demoDownload source Today we will create a collapsing menu that contains vertical navigation bars and a slide out content area. When hovering over a menu item, an image slides down from the top and a submenu slides up from the bottom. Clicking on one of the submenu items will make the whole menu collapse [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/CollapsingSiteNavigation/" target="_blank"><img class="aligncenter size-full wp-image-2723" title="collapsingsitenavigation" src="http://tympanus.net/codrops/wp-content/uploads/2010/09/collapsingsitenavigation.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CollapsingSiteNavigation/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/CollapsingSiteNavigation/CollapsingSiteNavigation.zip">Download source</a></p>
<p>Today we will create a collapsing menu that contains vertical navigation bars and a slide out content area. When hovering over a menu item, an image slides down from the top and a submenu slides up from the bottom. Clicking on one of the submenu items will make the whole menu collapse like a card deck and the respective content area will slide out.</p>
<p>The beautiful fashion photos are taken from <a href="http://www.flickr.com/photos/parisbeyrouth" target="_blank">Beyrouth&#8217;s photostream on flickr</a>. The specific set can be found <a href="http://www.flickr.com/photos/parisbeyrouth/sets/72157624331735811/" target="_blank">here</a>.</p>
<p>So, let&#8217;s get started!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>Our HTML will consist of a main container with the class and id &#8220;cc_menu&#8221;. Here we will place all our vertical menu items and the main content div:</p>
<pre class="brush:xml">&lt;div id="cc_menu" class="cc_menu"&gt;
	&lt;div class="cc_item" style="z-index:5;"&gt;
		&lt;img src="images/1.jpg" alt="image" /&gt;
		&lt;span class="cc_title"&gt;Collection&lt;/span&gt;
		&lt;div class="cc_submenu"&gt;
			&lt;ul&gt;
				&lt;li class="cc_content_1"&gt;Winter 2010&lt;/li&gt;
				&lt;li class="cc_content_2"&gt;Spring 2011&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div class="cc_item" style="z-index:4;"&gt;
		&lt;img src="images/2.jpg" alt="image" /&gt;
		&lt;span class="cc_title"&gt;Stores&lt;/span&gt;
		&lt;div class="cc_submenu"&gt;
			&lt;ul&gt;
				&lt;li class="cc_content_3"&gt;Milano&lt;/li&gt;
				&lt;li class="cc_content_4"&gt;Paris&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	...
	&lt;div id="cc_content" class="cc_content"&gt;
		&lt;span id="cc_back" class="cc_back"&gt;&lt;&lt; Go back&lt;/span&gt;
		&lt;div class="cc_content_1"&gt;
			&lt;h1&gt;Winter 2010&lt;/h1&gt;
			&lt;p&gt;Some content&lt;/p&gt;
		&lt;/div&gt;
		&lt;div class="cc_content_2"&gt;
			&lt;h1&gt;Spring 2011&lt;/h1&gt;
			&lt;p&gt;Some content&lt;/p&gt;
		&lt;/div&gt;
		...
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The first item will get a z-index of 5 and then we will decrease the z-index for the next items. This will make the last item be in the lowest layer. We do this in order to create the card deck collapsing effect.</p>
<p>Each submenu item will share its class with the respective content div. Like that we can make the right content div appear whenever we click on a submenu item.</p>
<p>Let&#8217;s take a look at the styling.</p>
<h3>The CSS</h3>
<p>Our main div that surrounds everything will have the following style:</p>
<pre class="brush:css">.cc_menu{
	width:700px; /*140px * 5*/
	height:600px;
	position:relative;
	font-size:14px;
	text-transform:uppercase;
	color:#fff;
}
</pre>
<p>The width of this container is the sum of all the item widths which is 5 times 140 pixels.</p>
<p>The style of each navigation item will be the following:</p>
<pre class="brush:css">.cc_item{
	text-align:center;
	width:140px;
	height:600px;
	float:left;
	border-bottom:1px solid #000;
	background:#444 url(../images/bg.png) repeat top left;
	position:relative;
	-moz-box-shadow:3px -3px 10px #000;
	-webkit-box-shadow:3px -3px 10px #000;
	box-shadow:3px -3px 10px #000;
}
</pre>
<p>We will give each item a box shadow so that the layering becomes visible. (That does not work in IE yet, so you will have to add a border or some other background image that enhances this.)</p>
<p>The title in each menu element will have a dark background with a subtle shadow around:</p>
<pre class="brush:css">span.cc_title{
	color:#fff;
	font-size:16px;
	top:200px;
	left:5px;
	position:absolute;
	padding:3px 0px;
	background:#111;
	width:130px;
	display:block;
	z-index:11;
	-moz-box-shadow:1px 1px 4px #000;
	-webkit-box-shadow:1px 1px 4px #000;
	box-shadow:1px 1px 4px #000;
}
</pre>
<p>The submenu list will be styled as follows:</p>
<pre class="brush:css">.cc_submenu ul{
	list-style:none;
	width:140px;
	margin:0;
	padding:0;
	height:0px; /*increase to 200px to slide up*/
	overflow:hidden;
	text-align:left;
	background:#000;
	position:absolute;
	left:0px;
	bottom:0px;
	opacity:0.7;
	z-index:13;
}
</pre>
<p>We will position the list at the bottom of the item and give it a height of 0 pixel. We will then increase the height to 200 pixels for it to slide up from the bottom.</p>
<p>The list elements of the submenu list will have the following style:</p>
<pre class="brush:css">.cc_submenu ul li{
	color:#ddd;
	cursor:pointer;
	padding:10px;
}
</pre>
<p>The image that will slide in from the top will be positioned negatively, meaning that we will hide it at the top of the item and the page:</p>
<pre class="brush:css">.cc_item img{
	position:absolute;
	width:140px;
	height:600px;
	top:-600px;
	left:0px;
}
</pre>
<p>In our JavaScript function we will make it slide down from the top by animating the top value to 0px.</p>
<p>The div that surrounds all the contents will also be hidden to the left of the page by setting the left value to -700 pixels:</p>
<pre class="brush:css">.cc_content{
	width:600px;
	height:600px;
	border-bottom:1px solid #000;
	position:absolute;
	left:-700px;
	background:#444 url(../images/bg.png) repeat top left;
	overflow:hidden;
	-moz-box-shadow:4px 0 7px #000;
	-webkit-box-shadow:4px 0 7px #000;
	box-shadow:4px 0 7px #000;
}
</pre>
<p>The single content divs will have the following style:</p>
<pre class="brush:css">.cc_content div{
	display:none;
	margin:20px;
}
</pre>
<p>We will give each paragraph the following style:</p>
<pre class="brush:css">.cc_content p{
	background:#000;
	padding:20px;
	opacity:0.7;
}
</pre>
<p>And finally, we will position the back span at the bottom right of the content container:</p>
<pre class="brush:css">span.cc_back{
	position:absolute;
	bottom:10px;
	right:10px;
	cursor:pointer;
	color:#ddd;
}
</pre>
<p>And that was the style. Now, let&#8217;s take a look at the JavaScript magic.</p>
<h3>The JavaScript</h3>
<p>We will have several function taking care of the behavior of our navigation. Whenever we hover a menu item, we want the image to slide in from the top and the submenu to slide in from the bottom. And, of course, when we leave an item, we want the reverse to happen. The functions <strong>m_enter</strong> and <strong>m_leave</strong> take care of that behavior.<br />
The function <strong>fold</strong> will make the menu collapse once a submenu item is clicked. The initial position is recovered by the function <strong>unfold</strong>.<br />
The two functions showContent and hideContent take care of the respective content appearing and disappearing.</p>
<p>In our main jQuery function we will start by defining some variables:</p>
<pre class="brush:js">//all the menu items
var $items 		= $('#cc_menu .cc_item');
//number of menu items
var cnt_items	= $items.length;
//if menu is expanded then folded is true
var folded		= false;
//timeout to trigger the mouseenter event on the menu items
var menu_time;
</pre>
<p>Now we will bind the mouseenter and the mouseleave to each item. We will also bind the click event to list elements in the submenu:</p>
<pre class="brush:js">$items.unbind('mouseenter')
	  .bind('mouseenter',m_enter)
	  .unbind('mouseleave')
	  .bind('mouseleave',m_leave)
	  .find('.cc_submenu &gt; ul &gt; li')
	  .bind('click',function(){
	var $li_e = $(this);
		  //if the menu is already folded,
		  //just replace the content
	if(folded){
		hideContent();
		showContent($li_e.attr('class'));
	}
		  else //fold and show the content
		fold($li_e);
});
</pre>
<p>In the following we will define the <strong>m_enter</strong> function:</p>
<pre class="brush:js">function m_enter(){
	var $this 	= $(this);
	clearTimeout(menu_time);
	menu_time 	= setTimeout(function(){
	//img
	$this.find('img').stop().animate({'top':'0px'},400);
	//cc_submenu ul
	$this.find('.cc_submenu &gt; ul').stop().animate({'height':'200px'},400);
	},200);
}
</pre>
<p>The timeout is used to prevent this event to trigger if the user moves the mouse with a considerable speed through the menu items.</p>
<p>The <strong>m_leave</strong> function is defined as follows:</p>
<pre class="brush:js">function m_leave(){
	var $this = $(this);
	clearTimeout(menu_time);
	//img
	$this.find('img').stop().animate({'top':'-600px'},400);
	//cc_submenu ul
	$this.find('.cc_submenu &gt; ul').stop().animate({'height':'0px'},400);
}
</pre>
<p>When clicking on the back span, we want the <strong>unfold</strong> function to trigger:</p>
<pre class="brush:js">$('#cc_back').bind('click',unfold);
</pre>
<p>The <strong>fold</strong> function will show only the menu column of the chosen submenu and make all the other items animate to the left by setting the margin to -140 pixels:</p>
<pre class="brush:js">function fold($li_e){
	var $item		= $li_e.closest('.cc_item');

	var d = 100;
	var step = 0;
	$items.unbind('mouseenter mouseleave');
	$items.not($item).each(function(){
		var $item = $(this);
		$item.stop().animate({
			'marginLeft':'-140px'
		},d += 200,function(){
			++step;
			if(step == cnt_items-1){
				folded = true;
				showContent($li_e.attr('class'));
			}
		});
	});
}
</pre>
<p>The unfold function shows all the menu items and also hides any item&#8217;s image and submenu that might be displayed:</p>
<pre class="brush:js">function unfold(){
	$('#cc_content').stop().animate({'left':'-700px'},600,function(){
		var d = 100;
		var step = 0;
	$items.each(function(){
			var $item = $(this);

			$item.find('img')
				 .stop()
				 .animate({'top':'-600px'},200)
				 .andSelf()
				 .find('.cc_submenu &gt; ul')
				 .stop()
				 .animate({'height':'0px'},200);

			$item.stop().animate({
			'marginLeft':'0px'
			},d += 200,function(){
				++step;
				if(step == cnt_items-1){
					folded = false;
					$items.unbind('mouseenter')
						  .bind('mouseenter',m_enter)
						  .unbind('mouseleave')
						  .bind('mouseleave',m_leave);

					hideContent();
				}
			});
		});
	});
}
</pre>
<p>The function to show the content will animate our content container to the right by setting the left value to 140 pixels. It will also fade in the respective content:</p>
<pre class="brush:js">function showContent(idx){
	$('#cc_content').stop().animate({'left':'140px'},200,function(){
		$(this).find('.'+idx).fadeIn();
	});
}
</pre>
<p>And finally, the function to hide the content:</p>
<pre class="brush:js">function hideContent(){
	$('#cc_content').find('div').hide();
}
</pre>
<p>To cufonize the font in our menu, we will simply add these lines to the head of our HTML:</p>
<pre class="brush:xml">&lt;script src="js/cufon-yui.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="js/Liberation_Sans.font.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
	Cufon.replace('span');
	Cufon.replace('li');
	Cufon.replace('h1');
	Cufon.replace('p');
&lt;/script&gt;
</pre>
<p>We will be using the font Liberation Sans which you can also find <a href="http://www.fontsquirrel.com/fonts/Liberation-Sans" target="_blank">here</a>.</p>
<p>And that&#8217;s all! We hope you enjoyed this tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CollapsingSiteNavigation/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/CollapsingSiteNavigation/CollapsingSiteNavigation.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/09/06/collapsing-site-navigation/feed/</wfw:commentRss>
		<slash:comments>124</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  tympanus.net/codrops/tag/sliding/feed/ ) in 0.35789 seconds, on May 24th, 2012 at 12:59 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 24th, 2012 at 1:59 am UTC -->
