<?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>AEXT.NET MAGAZINE &#187; Slide</title>
	<atom:link href="http://aext.net/tag/slide/feed/" rel="self" type="application/rss+xml" />
	<link>http://aext.net</link>
	<description>How to Create a Website</description>
	<lastBuildDate>Wed, 30 May 2012 05:03:57 +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>Learning jQuery: Horizontal Panel Sliding With animate() function</title>
		<link>http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/</link>
		<comments>http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 19:00:07 +0000</pubDate>
		<dc:creator>Lief</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Animate]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery Tutorial]]></category>
		<category><![CDATA[Learning jQuery]]></category>
		<category><![CDATA[Slide]]></category>

		<guid isPermaLink="false">http://aext.net/?p=1243</guid>
		<description><![CDATA[<p><a href="http://aext.net/theme/platinoom" title="Platinoom - Premium WordPress Themes"><img src="http://aext.net/wp-content/uploads/2011/04/platinoom_wordpress_theme.png" alt="ThemeKiss" /></a></p><p style="float: right;"><a href="http://api.tweetmeme.com/share?url=http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/&service=su.pr&service_api=b57727e991c454bd2b2c62ff71462c79"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/" height="61" width="51" /></a></p>This post is of the Learning jQuery series. Today, we will learn to use the <em>animate()</em> function to slide the panel to the left. It's useful for display your options for search page. By a trick, we will make the animation more simple. <a href="http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://aext.net/theme/platinoom" title="Platinoom - Premium WordPress Themes"><img src="http://aext.net/wp-content/uploads/2011/04/platinoom_wordpress_theme.png" alt="ThemeKiss" /></a></p><p style="float: right;"><a href="http://api.tweetmeme.com/share?url=http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/&service=su.pr&service_api=b57727e991c454bd2b2c62ff71462c79"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/" height="61" width="51" /></a></p><p>This post is of the Learning jQuery series. Today, we will learn to use the <em>animate()</em> function to slide the panel to the left. It&#8217;s useful for display your options for search page. By a trick, we will make the animation more simple.</p>
<p><span id="more-1243"></span></p>
<p><strong>Updated: </strong>I updated the code in the demo and download file. The previous version get error with IE7 by the extra comma in javascript code. Furthermore, I fixed the issue caused if the Left panel is taller than the Right Panel, the content of left side would be truncated. Thanks to roni &#038; B!</p>
<div class="demo-download">
<ul>
<li><a class="downloadit" href="http://www.box.net/shared/c3o760zith">Download</a></li>
<li><a class="demoit" href="http://aext.net/example/slide-panel-jquery/">Demo</a></li>
</ul>
</div>
<h3>HTML</h3>
<hr />
<p>Look at the demo, someone will think we are gonna create a HTML code like image below &#8230;</p>
<div class="bigimage">
<img src="http://aext.net/wp-contents/uploads/2009/11/Learning-jQuery-Horizontal-Panel-Sliding-With-animate-function1.png" alt="Learning jQuery Horizontal Panel Sliding With animate function" title="Learning jQuery Horizontal Panel Sliding With animate function" width="500" height="340" class="aligncenter size-full wp-image-1269" />
</div>
<p>But we&#8217;re not gonna do as above. Because, when you do as above, you have to write javascript code to animate both of your left and right panel. If the left panel  animates, but the right panel doesn&#8217;t, your right panel will keep the original size. We need to expand the width of right side if the left side animates. So, we are not gonna slide the left panel. The left panel will be inside the content. As the result, when we slide content panel to the left, of course, the left panel will animate, too. Out HTML code is:</p>
<div class="bigimage">
<img src="http://aext.net/wp-contents/uploads/2009/11/Learning-jQuery-Horizontal-Panel-Sliding-With-animate-function-2.png" alt="Learning jQuery Horizontal Panel Sliding With animate function 2" title="Learning jQuery Horizontal Panel Sliding With animate function 2" width="500" height="340" class="aligncenter size-full wp-image-1272" />
</div>
<p>The HTML code below is very simple. Copy and paste these HTML code below into your HTML file:</p>
<pre class="html">
<span style="color:#881280;">&lt;div </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;wrap&quot;</span><span style="color:#881280;">&gt;</span>
&nbsp;&nbsp;<span style="color:#881280;">&lt;div </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;control&quot;</span><span style="color:#881280;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;a </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;controlbtn&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">class</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;open&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">href</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;http://aext.net&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">alt</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;Show/View your stuffs&quot;</span><span style="color:#881280;">&gt;</span>Hide your stuffs<span style="color:#881280;">&lt;/a&gt;</span>
&nbsp;&nbsp;<span style="color:#881280;">&lt;/div&gt;</span>
&nbsp;&nbsp;
&nbsp;&nbsp;<span style="color:#881280;">&lt;div </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;maincontent&quot;</span><span style="color:#881280;">&gt;</span>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;div </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;linkblock&quot;</span><span style="color:#881280;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;h4&gt;</span>All tags<span style="color:#881280;">&lt;/h4&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;ul </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;yourlist&quot;</span><span style="color:#881280;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;a </span><span style="color:#994500;">href</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;http://aext.net/category/css/&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">title</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;CSS &amp; XHTML&quot;</span><span style="color:#881280;">&gt;</span> CSS &amp; XHTML<span style="color:#881280;">&lt;/a&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;/li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;a </span><span style="color:#994500;">href</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;http://aext.net/category/php/&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">title</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;Resources&quot;</span><span style="color:#881280;">&gt;</span> PHP<span style="color:#881280;">&lt;/a&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;/li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;a </span><span style="color:#994500;">href</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;http://aext.net/category/resources/&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">title</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;Resources&quot;</span><span style="color:#881280;">&gt;</span> Resources<span style="color:#881280;">&lt;/a&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;/li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;a </span><span style="color:#994500;">href</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;http://aext.net/category/theme-layout/&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">title</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;Themes &amp; Layouts&quot;</span><span style="color:#881280;">&gt;</span> Themes &amp; Layouts<span style="color:#881280;">&lt;/a&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;/li&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;/ul&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;/div&gt;</span>
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;p&gt;</span>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi .... <span style="color:#881280;">&lt;/p&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;p&gt;</span>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi .... <span style="color:#881280;">&lt;/p&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;p&gt;</span>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi .... <span style="color:#881280;">&lt;/p&gt;</span>
&nbsp;&nbsp;
&nbsp;&nbsp;<span style="color:#881280;">&lt;/div&gt;</span>

<span style="color:#881280;">&lt;/div&gt;</span>
</pre>
<h3>CSS Code</h3>
<hr />
The following css code is used for styling the wrapper:</p>
<pre class="css">
div#wrap {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">position</span>: <span style="color:#9b4400;">relative</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">width</span>: <span style="color:#0000ff;">800px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">overflow</span>: <span style="color:#9b4400;">hidden</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin</span>: <span style="color:#0000ff;">100px</span> <span style="color:#9b4400;">auto</span> <span style="color:#0000ff;">0px</span> <span style="color:#9b4400;">auto</span>;
}
</pre>
<p>Remember to set the overflow hidden. Because, when the animation completed, the panel which one you want to hide, will go to the left side and go out side of the wrap. We use hidden value for overflow to hide this panel.</p>
<p>CSS code below makes up the link button:</p>
<pre class="css">
a#controlbtn{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">color</span>: <span style="color:#760f15;">#333</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">text-decoration</span>: <span style="color:#9b4400;">none</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">display</span>: <span style="color:#9b4400;">inline-block</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">padding-left</span>: <span style="color:#0000ff;">20px</span>;
}

a#controlbtn.open {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">background</span>: <span style="color:#9b4400;">transparent</span> <span style="color:#9b4400;">url</span><span style="color:#760f15;">(images/toggle_minus.png)</span> <span style="color:#9b4400;">no-repeat</span> <span style="color:#9b4400;">left</span> <span style="color:#9b4400;">center</span>;
}

a#controlbtn.close {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">background</span>: <span style="color:#9b4400;">transparent</span> <span style="color:#9b4400;">url</span><span style="color:#760f15;">(images/toggle_plus.png)</span> <span style="color:#9b4400;">no-repeat</span> <span style="color:#9b4400;">left</span> <span style="color:#9b4400;">center</span>;
}
</pre>
<p>We will change the toggle icon when users click on the link to show or hide the panel.</p>
<p>Anything else with CSS:</p>
<pre class="css">
div#linkblock {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">float</span>: <span style="color:#9b4400;">left</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">width</span>: <span style="color:#0000ff;">140px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin-left</span>: -<span style="color:#0000ff;">150px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">border-right</span>: <span style="color:#9b4400;">solid</span> <span style="color:#0000ff;">1px</span> <span style="color:#760f15;">#DDDDDD</span>;
}

div#maincontent {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">position</span>: <span style="color:#9b4400;">relative</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin-left</span>: <span style="color:#0000ff;">150px</span>;
}

#yourlist {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">list-style</span>: <span style="color:#9b4400;">none</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin</span>: <span style="color:#0000ff;">0px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">padding</span>: <span style="color:#0000ff;">0px</span>;
}
#yourlist li {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">padding</span>: <span style="color:#0000ff;">3px</span> <span style="color:#0000ff;">5px</span> <span style="color:#0000ff;">3px</span> <span style="color:#0000ff;">0px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">position</span>: <span style="color:#9b4400;">relative</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin-top</span>: <span style="color:#0000ff;">0</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin-right</span>: <span style="color:#0000ff;">0</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin-bottom</span>: <span style="color:#0000ff;">5px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin-left</span>: <span style="color:#0000ff;">0</span>;

}

#yourlist li a {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">color</span>: <span style="color:#760f15;">#D4432F</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">padding</span>: <span style="color:#9b4400;">none</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin</span>: <span style="color:#9b4400;">none</span>;
}

h4 {
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">margin</span>: <span style="color:#0000ff;">0px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">font-size</span>: <span style="color:#0000ff;">16px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">line-height</span>: <span style="color:#0000ff;">26px</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">color</span>: <span style="color:#760f15;">#333333</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">font-family</span>: Helvetica, Arial, <span style="color:#9b4400;">sans-serif</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">font-weight</span>: <span style="color:#9b4400;">bold</span>;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#88134f;">clear</span>: <span style="color:#9b4400;">none</span>;
}
</pre>
<p>Because, the <em>div#linkblock</em>&#8216;s position is absolute, we have to set position of <em>div#maincontent</em> relative. If not, absolute positioning will place based on the body size.</p>
<h3>Working with Javascript</h3>
<hr />At first, we call <em>$(document).ready()</em> function to load everything inside it as soon as the DOM is loaded and before the page contents are loaded.</p>
<pre class="javascript">
<span style="color:#881280;">&lt;script </span><span style="color:#994500;">type</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;text/javascript&quot;</span><span style="color:#881280;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;$(document).<span style="color:#003369;">ready</span>(<span style="color:#881350;">function</span>() {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em><span style="color:#236e25;">// We will work here
</span></em>
&nbsp;&nbsp;&nbsp;&nbsp;});
<span style="color:#881280;">&lt;/script&gt;</span>
</pre>
<p>Next, will write some code to know the link click event.</p>
<p><em>e.preventDefault();</em> is used for disable default action of the link. When you click on the link, nothing will happen.</p>
<pre class="javascript">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#760f15;">&quot;a#controlbtn&quot;</span>).<span style="color:#003369;">click</span>(<span style="color:#881350;">function</span>(e) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.<span style="color:#003369;">preventDefault</span>();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;....

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
</pre>
<p>Next part, the script need to know when does the panel slide to the left or right.</p>
<pre class="javascript">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">var</span> slidepx=$(<span style="color:#760f15;">&quot;div#linkblock&quot;</span>).<span style="color:#003369;">width</span>() + <span style="color:#0000ff;">10</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">if</span><span style="color:#003369;"> </span>(<span style="color:#003369;">parseInt</span>($(<span style="color:#760f15;">&quot;div#maincontent&quot;</span>).<span style="color:#003369;">css</span>(<span style="color:#760f15;">'marginLeft'</span>), <span style="color:#0000ff;">10</span>) &lt; slidepx) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#881350;">this</span>).<span style="color:#003369;">removeClass</span>(<span style="color:#760f15;">'close'</span>).<span style="color:#003369;">html</span>(<span style="color:#760f15;">'Hide your stuffs'</span>);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin = <span style="color:#760f15;">&quot;+=&quot;</span> + slidepx;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <span style="color:#881350;">else</span> {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#881350;">this</span>).<span style="color:#003369;">addClass</span>(<span style="color:#760f15;">'close'</span>).<span style="color:#003369;">html</span>(<span style="color:#760f15;">'Show your stuffs'</span>);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin = <span style="color:#760f15;">&quot;-=&quot;</span> + slidepx;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
</pre>
<p><em>slidepx</em> is an amount in pixel that we will slide the panel. We get that by the width of the panel we want to hide, and plus with 10px is the amount that panel margins. See the CSS code to know why I plus 10px here.</p>
<p>Finally, animate the panel by code below.</p>
<p>The first line in the code is used for detecting if the panel is not animating.</p>
<pre class="javascript">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">if</span><span style="color:#003369;"> </span>( !$(<span style="color:#760f15;">&quot;div#maincontent&quot;</span>).<span style="color:#003369;">is</span>(<span style="color:#760f15;">':animated'</span>) ) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#760f15;">&quot;div#maincontent&quot;</span>).<span style="color:#003369;">animate</span>({
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;marginLeft: margin,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}, <span style="color:#0000ff;">300</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
</pre>
<p>Animate with easing jquery plugin:</p>
<pre class="javascript">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">if</span><span style="color:#003369;"> </span>( !$(<span style="color:#760f15;">&quot;div#maincontent&quot;</span>).<span style="color:#003369;">is</span>(<span style="color:#760f15;">':animated'</span>) ) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#760f15;">&quot;div#maincontent&quot;</span>).<span style="color:#003369;">animate</span>({
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;marginLeft: margin,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}, {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;duration: <span style="color:#760f15;">'slow'</span>,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easing: <span style="color:#760f15;">'easeOutQuint'</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
</pre>
<div class="txtad-cont">
<div class="txtad-ad">If you are a new to web designing and looking for free resources to learn web designing, then <a href="http://www.actualtests.com/exam-CISA.htm">CISA</a> online course is perfect for you. We offer best quality <a href="http://www.actualtests.com/exam-NS0-163.htm">NS0-163</a> videos and <a href="http://www.actualtests.com/exam-642-566.htm">642-566</a> design guide to help you learn how to design your own web page.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://aext.net/2009/11/learning-jquery-horizontal-panel-sliding-with-animate-function/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>

