<?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>Script Tutorials &#187; animation | Script Tutorials | Web development</title> <atom:link href="http://www.script-tutorials.com/tag/animation/feed/" rel="self" type="application/rss+xml" /><link>http://www.script-tutorials.com</link> <description>Tutorials for Web Developers</description> <lastBuildDate>Fri, 03 Feb 2012 06:07:51 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Analog Clock with Pure CSS3 (without javascript)</title><link>http://www.script-tutorials.com/analog-clock-with-pure-css3/</link> <comments>http://www.script-tutorials.com/analog-clock-with-pure-css3/#comments</comments> <pubDate>Thu, 05 Jan 2012 15:00:59 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[clock]]></category> <category><![CDATA[css3]]></category> <category><![CDATA[rotate]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1343</guid> <description><![CDATA[Analog Clock with Pure CSS3 (without javascript) Today &#8211; another one great article &#8211; we are going to create pure CSS3 Analog Clock without any javascript (we are going to use power of CSS3 with animations to build it). Our clocks have three arrows on the face &#8211; hour, minute and second. Each of them [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/css3-optical-illusions/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/212/thumb.png" alt="CSS3 Optical Illusions" /> CSS3 Optical Illusions</a></li><li> <a
href="http://www.script-tutorials.com/creating-css3-animated-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/126/thumb.png" alt="Creating A CSS3 Animated Menu" /> Creating A CSS3 Animated Menu</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-a-pure-css3-slideshow/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/204/thumb.png" alt="How to Create a Pure CSS3 Slideshow" /> How to Create a Pure CSS3 Slideshow</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Analog Clock with Pure CSS3 (without javascript)" alt="Analog Clock with Pure CSS3 (without javascript)" src="http://www.script-tutorials.com/demos/213/thumb.png" /></div><p><strong>Analog Clock with Pure CSS3 (without javascript)</strong></p><p>Today &#8211; another one great article &#8211; we are going to create pure CSS3 Analog Clock without any javascript (we are going to use power of CSS3 with animations to build it). Our clocks have three arrows on the face &#8211; hour, minute and second. Each of them &#8211; a narrow rectangle rotated to the desired angle. How it works in result? &#8211; Easy, I am using necessary delays for all these arrows. How exactly &#8211; read on.</p><p><span
id="more-1343"></span></p><hr
/><p>For our clock &#8211; I have prepared -webkit and -moz styles. So please keep in mind &#8211; that clock will work only in Firefox, and Webkit-based browsers (Chrome and Safari). If you like &#8211; you always can expand necessary styles (for arrows) for IE and Opera browsers (by adding same stylesheets with -ms and -o prefixes).</p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Analog Clock with Pure CSS3 (without javascript) - demo 213" href="http://www.script-tutorials.com/demos/213/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Analog Clock with Pure CSS3 (without javascript) - package" href="http://www.script-tutorials.com/demos/213/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML markup</h3><p>The mark-up for our clock is not very simple &#8211; it contain lot of DIV elements. Each of them &#8211; our arrows. Here it is.</p><h4>index.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Analog Clock with Pure CSS3 (without javascript) | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/layout.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;&gt;
        &lt;link href=&quot;css/clocks.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;header&gt;
            &lt;h2&gt;Analog Clock with Pure CSS3 (without javascript)&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/analog-clock-with-pure-css3/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/header&gt;
        &lt;div class=&quot;container&quot;&gt;
            &lt;div id=&quot;clock&quot;&gt;
                &lt;div class=&quot;secs&quot;&gt;
                    &lt;div id=&quot;s1&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s2&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s3&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s4&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s5&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s6&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s7&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s8&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s9&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s10&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s11&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s12&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s13&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s14&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s15&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s16&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s17&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s18&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s19&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s20&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s21&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s22&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s23&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s24&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s25&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s26&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s27&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s28&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s29&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s30&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s31&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s32&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s33&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s34&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s35&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s36&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s37&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s38&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s39&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s40&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s41&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s42&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s43&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s44&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s45&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s46&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s47&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s48&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s49&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s50&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s51&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s52&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s53&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s54&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s55&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s56&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s57&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;s58&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s59&quot;&gt;&lt;/div&gt;&lt;div id=&quot;s60&quot;&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;mins&quot;&gt;
                    &lt;div id=&quot;m1&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m2&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m3&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m4&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m5&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m6&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m7&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m8&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m9&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m10&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m11&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m12&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m13&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m14&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m15&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m16&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m17&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m18&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m19&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m20&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m21&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m22&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m23&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m24&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m25&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m26&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m27&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m28&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m29&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m30&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m31&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m32&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m33&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m34&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m35&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m36&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m37&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m38&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m39&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m40&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m41&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m42&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m43&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m44&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m45&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m46&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m47&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m48&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m49&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m50&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m51&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m52&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m53&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m54&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m55&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m56&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m57&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;m58&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m59&quot;&gt;&lt;/div&gt;&lt;div id=&quot;m60&quot;&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;hours&quot;&gt;
                    &lt;div id=&quot;h1&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h2&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h3&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;h4&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h5&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h6&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;h7&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h8&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h9&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;h10&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h11&quot;&gt;&lt;/div&gt;&lt;div id=&quot;h12&quot;&gt;&lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><h3>Step 2. CSS</h3><p>Now &#8211; CSS styles. As usual, we won&#8217;t publish main page layout styles (layout.css). But, there are stylesheets for our clock:</p><h4>css/clocks.css</h4><pre class="brush:css">
#clock {
    background: #fff url(cface.png) 0 0 no-repeat;
    height: 500px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    width: 500px;

    -webkit-border-radius: 250px;
    -moz-border-radius: 250px;
    -ms-border-radius: 250px;
    -o-border-radius: 250px;
    border-radius: 250px;
}

/* seconds */
@-webkit-keyframes secs_effect {
    0% {opacity: 1;}
    1.66% {opacity: 1;}
    1.67% {opacity: 0;}
    100% {opacity: 0;}
}
@-moz-keyframes secs_effect {
    0% {opacity: 1;}
    1.66% {opacity: 1;}
    1.67% {opacity: 0;}
    100% {opacity: 0;}
}

#clock  .secs {
    height: 400px;
    left: 155px;
    position: absolute;
    top: 249px;
    width: 400px;
}
#clock  .secs div {
    background-color: #860000;
    height: 2px;
    opacity: 0;
    position: absolute;
    width: 190px;

    -moz-animation-name: secs_effect;
    -moz-animation-duration: 60s;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;
    -moz-animation-direction: normal;
    -moz-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;

    -webkit-animation-name: secs_effect;
    -webkit-animation-duration: 60s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: normal;
    -webkit-animation-delay: 0;
    -webkit-animation-play-state: running;
    -webkit-animation-fill-mode: forwards;
}

#clock #s1 {
-moz-transform: rotate(-90deg) translatex(130px);
-moz-animation-delay: 0s;
-webkit-transform: rotate(-90deg) translatex(130px);
-webkit-animation-delay: 0s;
}
#clock #s2 {
-moz-transform: rotate(-84deg) translatex(130px);
-moz-animation-delay: 1s;
-webkit-transform: rotate(-84deg) translatex(130px);
-webkit-animation-delay: 1s;
}
#clock #s3 {
-moz-transform: rotate(-78deg) translatex(130px);
-moz-animation-delay: 2s;
-webkit-transform: rotate(-78deg) translatex(130px);
-webkit-animation-delay: 2s;
}
...........
#clock #s60 {
-moz-transform: rotate(264deg) translatex(130px);
-moz-animation-delay: 59s;
-webkit-transform: rotate(264deg) translatex(130px);
-webkit-animation-delay: 59s;
}

/* minutes */
@-webkit-keyframes mins_effect {
    0% {opacity: 1;}
    1.66% {opacity: 1;}
    1.67% {opacity: 0;}
    100% {opacity: 0;}
}
@-moz-keyframes mins_effect {
    0% {opacity: 1;}
    1.66% {opacity: 1;}
    1.67% {opacity: 0;}
    100% {opacity: 0;}
}

#clock  .mins {
    height: 300px;
    left: 175px;
    position: absolute;
    top: 249px;
    width: 300px;
}
#clock  .mins div {
    background-color: #000086;
    height: 3px;
    opacity: 0;
    position: absolute;
    width: 150px;

    -moz-animation-name: mins_effect;
    -moz-animation-duration: 3600s;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;
    -moz-animation-direction: normal;
    -moz-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;

    -webkit-animation-name: mins_effect;
    -webkit-animation-duration: 3600s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: normal;
    -webkit-animation-delay: 0;
    -webkit-animation-play-state: running;
    -webkit-animation-fill-mode: forwards;
}

#clock #m1 {
-moz-transform: rotate(-90deg) translatex(110px);
-moz-animation-delay: 0s;
-webkit-transform: rotate(-90deg) translatex(110px);
-webkit-animation-delay: 0s;
}
#clock #m2 {
-moz-transform: rotate(-84deg) translatex(110px);
-moz-animation-delay: 60s;
-webkit-transform: rotate(-84deg) translatex(110px);
-webkit-animation-delay: 60s;
}
#clock #m3 {
-moz-transform: rotate(-78deg) translatex(110px);
-moz-animation-delay: 120s;
-webkit-transform: rotate(-78deg) translatex(110px);
-webkit-animation-delay: 120s;
}
...........
#clock #m60 {
-moz-transform: rotate(264deg) translatex(110px);
-moz-animation-delay: 3540s;
-webkit-transform: rotate(264deg) translatex(110px);
-webkit-animation-delay: 3540s;
}

/* hours */
@-webkit-keyframes hours_effect {
    0% {opacity: 1;}
    8.33% {opacity: 1;}
    8.34% {opacity: 0;}
    100% {opacity: 0;}
}
@-moz-keyframes hours_effect {
    0% {opacity: 1;}
    8.33% {opacity: 1;}
    8.34% {opacity: 0;}
    100% {opacity: 0;}
}

#clock  .hours {
    height: 300px;
    left: 175px;
    position: absolute;
    top: 249px;
    width: 300px;
}
#clock  .hours div {
    background-color: #860086;
    height: 3px;
    opacity: 0;
    position: absolute;
    width: 150px;

    -moz-animation-name: hours_effect;
    -moz-animation-duration: 43200s;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;
    -moz-animation-direction: normal;
    -moz-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;

    -webkit-animation-name: hours_effect;
    -webkit-animation-duration: 43200s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: normal;
    -webkit-animation-delay: 0;
    -webkit-animation-play-state: running;
    -webkit-animation-fill-mode: forwards;
}

#clock #h1 {
-moz-transform: rotate(-180deg) translatex(110px);
-moz-animation-delay: 0s;
-webkit-transform: rotate(-180deg) translatex(110px);
-webkit-animation-delay: 0s;
}
#clock #h2 {
-moz-transform: rotate(-150deg) translatex(110px);
-moz-animation-delay: 3600s;
-webkit-transform: rotate(-150deg) translatex(110px);
-webkit-animation-delay: 3600s;
}
#clock #h3 {
-moz-transform: rotate(-120deg) translatex(110px);
-moz-animation-delay: 7200s;
-webkit-transform: rotate(-120deg) translatex(110px);
-webkit-animation-delay: 7200s;
}
...........
#clock #h12 {
-moz-transform: rotate(150deg) translatex(110px);
-moz-animation-delay: 39600s;
-webkit-transform: rotate(150deg) translatex(110px);
-webkit-animation-delay: 39600s;
}
</pre><p>Now &#8211; you can understand the main idea. I won&#8217;t publish all &#8216;recurring&#8217; styles for each arrow. Full code you can find in our package.</p><h3>Step 4. Images</h3><p>For our clock I have used single image (as face of our clock):</p><p> <img
src="http://www.script-tutorials.com/demos/213/css/cface.png" alt="Analog Clock with Pure CSS3 | Script Tutorials" /></p><hr
/><h5 style="text-align: center;"><strong><a
title="Analog Clock with Pure CSS3 (without javascript) - demo 213" href="http://www.script-tutorials.com/demos/213/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Analog Clock with Pure CSS3 (without javascript) - package" href="http://www.script-tutorials.com/demos/213/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Finally we have built our clock! This was difficult, but we did it. I hope that this will interesting addition to your website. Don&#8217;t forget to tell thanks and leave a comment. Good luck!</p><div
class="shr-publisher-1343"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/css3-optical-illusions/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/212/thumb.png" alt="CSS3 Optical Illusions" /> <br
/> CSS3 Optical Illusions</a></li><li> <a
href="http://www.script-tutorials.com/creating-css3-animated-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/126/thumb.png" alt="Creating A CSS3 Animated Menu" /> <br
/> Creating A CSS3 Animated Menu</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-a-pure-css3-slideshow/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/204/thumb.png" alt="How to Create a Pure CSS3 Slideshow" /> <br
/> How to Create a Pure CSS3 Slideshow</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/analog-clock-with-pure-css3/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Cool Background Image Sliding effect with jQuery</title><link>http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/</link> <comments>http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/#comments</comments> <pubDate>Fri, 18 Nov 2011 17:55:19 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[background]]></category> <category><![CDATA[effect]]></category> <category><![CDATA[sliding]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1222</guid> <description><![CDATA[Cool Background Image Sliding effect with jQuery Today I am going to show you how to create sliding image cell effect. This is will something like small photo gallery. I prepared 3 demos for you with different effects. Please pay attention that our demo will work in browsers that support used CSS3 properties. Live Demo [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/71/thumb.png" alt="Cross-browser Supported Image Skew effect using Javascript" /> Cross-browser Supported Image Skew effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/jquery-css-tutorial-zooming-image/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/3/images/ajax_small.gif" alt="Jquery CSS Tutorial on Zooming Image" /> Jquery CSS Tutorial on Zooming Image</a></li><li> <a
href="http://www.script-tutorials.com/creating-css3-drop-sliding-list-menu-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/113/thumb.png" alt="Creating CSS3 Drop sliding list Menu #6" /> Creating CSS3 Drop sliding list Menu #6</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Cool Background Image Sliding effect with jQuery" alt="Cool Background Image Sliding effect with jQuery" src="http://www.script-tutorials.com/demos/185/thumb.png"></div><p><strong>Cool Background Image Sliding effect with jQuery</strong><br
/> <br
/>Today I am going to show you how to create sliding image cell effect. This is will something like small photo gallery. I prepared 3 demos for you with different effects. Please pay attention that our demo will work in browsers that support used CSS3 properties.<br
/> <span
id="more-1222"></span></p><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - demo 185" href="http://www.script-tutorials.com/demos/185/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - package" href="http://www.script-tutorials.com/demos/185/source.zip" target="_blank">download result</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>Here are full html code of our result. For our demonstration I use 5 photos &#8211; same amount of &#8216;navigation&#8217; elements you can see here too.</p><h4>index.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Cool Background Image Sliding effect with jQuery | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

        &lt;!--[if lt IE 9]&gt;
          &lt;script src=&quot;http://html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
        &lt;![endif]--&gt;
        &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div class=&quot;container&quot; id=&quot;container&quot;&gt;
            &lt;ul class=&quot;nav&quot;&gt;
                &lt;li id=&quot;m1&quot;&gt;Pic 1&lt;/li&gt;
                &lt;li id=&quot;m2&quot;&gt;Pic 2&lt;/li&gt;
                &lt;li id=&quot;m3&quot;&gt;Pic 3&lt;/li&gt;
                &lt;li id=&quot;m4&quot;&gt;Pic 4&lt;/li&gt;
                &lt;li id=&quot;m5&quot;&gt;Pic 5&lt;/li&gt;
            &lt;/ul&gt;

            &lt;ul class=&quot;grid&quot;&gt;
                &lt;li id=&quot;g1&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g2&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g3&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g4&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g5&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g6&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
            &lt;ul class=&quot;demos&quot;&gt;
                &lt;li&gt;&lt;a href=&quot;index.html&quot;&gt;Demo 1&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;index2.html&quot;&gt;Demo 2&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;index3.html&quot;&gt;Demo 3&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
        &lt;footer&gt;
            &lt;h2&gt;Cool Background Image Sliding effect with jQuery&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/footer&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><h3>Step 2. CSS</h3><p>Now &#8211; our CSS styles. I will omit unnecessary styles of page layout, but will show you most important</p><h4>css/main.css</h4><pre class="brush:css">
.nav {
    background-color:#DDD;
    list-style:none outside none;
    overflow:hidden;
    padding:5px 140px;
}
.nav li {
    border-radius:10px;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;

    border:2px outset #000000;
    color:#000;
    cursor:pointer;
    float:left;
    font-size:18px;
    font-weight:bold;
    margin-right:5px;
    padding:10px;
}

.demos {
    background-color:#DDD;
    list-style:none outside none;
    overflow:hidden;
    padding:5px 165px;
}
.demos li {
    border-radius:10px;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;

    border:2px outset #000000;
    color:#000;
    float:left;
    font-size:18px;
    font-weight:bold;
    margin-right:5px;
    padding:10px;
}
.demos li a {
    color:#000;
    cursor:pointer;
    display:block;
    font-size:20px;
    font-weight:bold;
    height:30px;
    line-height:30px;
    text-decoration:none;
}

.grid {
    background-color:#DDD;
    list-style:none outside none;
    width:100%;
}
.grid li {
    border:1px solid #777777;
    float:left;
    height:240px;
    width:211px;

    transition:all 0.5s linear;
    -moz-transition:all 0.5s linear;
    -o-transition:all 0.5s linear;
    -webkit-transition:all 0.5s linear;
}
.grid li div {
    transition:all 0.5s ease-in-out;
    -moz-transition:all 0.5s ease-in-out;
    -o-transition:all 0.5s ease-in-out;
    -webkit-transition:all 0.5s ease-in-out;

    float:left;
}
.grid li .d1 {
    background:transparent url(../images/grid1.jpg) no-repeat top left;
    height:100%;
    width:211px;
}
.grid li .d2 {
    background:transparent url(../images/grid2.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li .d3 {
    background:transparent url(../images/grid3.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li .d4 {
    background:transparent url(../images/grid4.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li .d5 {
    background:transparent url(../images/grid5.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li#g2 div {
    background-position:-211px 0;
}
.grid li#g3 div {
    background-position:-422px 0;
}
.grid li#g4 div {
    background-position:0 -240px;
}
.grid li#g5 div {
    background-position:-211px -240px;
}
.grid li#g6 div {
    background-position:-422px -240px;
}
</pre><p>As you can see &#8211; each grid cell element (LI) have some defined background, but with own background positions. And, I will use jQuery &#8216;animate&#8217; to shift these positions when we will switch our images (through navigation)</p><h3>Step 3. jQuery</h3><h4>js/main.js</h4><pre class="brush:js">
$(function(){
    $(&quot;.nav li&quot;).hover(
      function () {
        $('.grid li div').stop().animate({width:&quot;0&quot;},0);

        var ind = $(&quot;.nav li&quot;).index(this);
        $($('.grid li#g1 div')[ind]).stop().animate({width:&quot;211px&quot;},0);
        $($('.grid li#g2 div')[ind]).stop().animate({width:&quot;211px&quot;},50);
        $($('.grid li#g3 div')[ind]).stop().animate({width:&quot;211px&quot;},100);
        $($('.grid li#g4 div')[ind]).stop().animate({width:&quot;211px&quot;},150);
        $($('.grid li#g5 div')[ind]).stop().animate({width:&quot;211px&quot;},200);
        $($('.grid li#g6 div')[ind]).stop().animate({width:&quot;211px&quot;},250);
      }
    );
});
</pre><p>As you can see &#8211; all very easy.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - demo 185" href="http://www.script-tutorials.com/demos/185/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - package" href="http://www.script-tutorials.com/demos/185/source.zip" target="_blank" rel="nofollow">download result</a></strong></h5><hr
/><h3>Conclusion</h3><p>All another demos very similar, only few changes in styles and javascript code. You are welcome to play with our demos. Good luck!</p><div
class="shr-publisher-1222"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/71/thumb.png" alt="Cross-browser Supported Image Skew effect using Javascript" /> <br
/> Cross-browser Supported Image Skew effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/jquery-css-tutorial-zooming-image/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/3/images/ajax_small.gif" alt="Jquery CSS Tutorial on Zooming Image" /> <br
/> Jquery CSS Tutorial on Zooming Image</a></li><li> <a
href="http://www.script-tutorials.com/creating-css3-drop-sliding-list-menu-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/113/thumb.png" alt="Creating CSS3 Drop sliding list Menu #6" /> <br
/> Creating CSS3 Drop sliding list Menu #6</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Creating an Animated 3D WebGL Demonstration</title><link>http://www.script-tutorials.com/making-3d-webgl-demonstration/</link> <comments>http://www.script-tutorials.com/making-3d-webgl-demonstration/#comments</comments> <pubDate>Mon, 12 Sep 2011 17:45:18 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[3d]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[demo]]></category> <category><![CDATA[demonstration]]></category> <category><![CDATA[object]]></category> <category><![CDATA[webgl]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=995</guid> <description><![CDATA[Making 3D WebGL demonstration Today we continue HTML5 canvas examples. And today we will try to begin learning WebGL. In my demonstration I will show you how to initialize WebGL and draw simple 3D object. Also we will animate this object too. Here are our demo and downloadable package: Live Demo download in package Ok, [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/webgl-box-photo-slideshow/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/174/thumb.png" alt="Creating a 3D Animated Box HTML5 WebGL Photo Slideshow" /> Creating a 3D Animated Box HTML5 WebGL Photo Slideshow</a></li><li> <a
href="http://www.script-tutorials.com/twisting-images-webgl/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/144/thumb.png" alt="Creating a Keyboard Sensitive 3D Twisted Images in WebGl" /> Creating a Keyboard Sensitive 3D Twisted Images in WebGl</a></li><li> <a
href="http://www.script-tutorials.com/creating-photo-array-in-webgl/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/165/thumb.png" alt="Creating a Photo Array in WebGL" /> Creating a Photo Array in WebGL</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Making 3D WebGL demonstration" alt="Making 3D WebGL demonstration" src="http://www.script-tutorials.com/demos/139/thumb.png"></div><p><strong>Making 3D WebGL demonstration</strong><br
/> <br
/>Today we continue HTML5 canvas examples. And today we will try to begin learning WebGL. In my demonstration I will show you how to initialize WebGL and draw simple 3D object. Also we will animate this object too.<br
/> <span
id="more-995"></span><br
/></p><p>Here are our demo and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Making 3D WebGL demonstration - demo 139" href="http://www.script-tutorials.com/demos/139/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Making 3D WebGL demonstration - demo 139" href="http://www.script-tutorials.com/demos/139/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>Here are html source code of our demo. As you can see &#8211; just empty page.</p><h4>index.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/glMatrix-0.9.5.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/webgl-utils.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/script.js&quot;&gt;&lt;/script&gt;
    &lt;title&gt;WebGL demonstration | Script Tutorials&lt;/title&gt;
&lt;/head&gt;
&lt;body onload=&quot;initWebGl();&quot;&gt;
    &lt;div class=&quot;example&quot;&gt;
        &lt;h3&gt;&lt;a href=&quot;http://www.script-tutorials.com/making-3d-webgl-demonstration/&quot;&gt;WebGL demonstration | Script Tutorials&lt;/a&gt;&lt;/h3&gt;
        &lt;canvas id=&quot;panel&quot; width=&quot;500&quot; height=&quot;333&quot;&gt;&lt;/canvas&gt;
        &lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><h3>Step 2. CSS</h3><p>Here are used CSS styles.</p><h4>css/main.css</h4><pre class="brush:css">
body {
    background:#eee;
    font-family:Verdana, Helvetica, Arial, sans-serif;
    margin:0;
    padding:0
}
.example {
    background:#fff;
    width:500px;
    font-size:80%;
    border:1px #000 solid;
    margin:20px auto;
    padding:15px;
    position:relative;
    -moz-border-radius: 3px;
    -webkit-border-radius:3px
}
h3 {
    text-align:center;
}
</pre><h3>Step 3. JS</h3><h4>js/webgl-utils.js and js/glMatrix-0.9.5.min.js</h4><p>These files we will use in project for working with WebGL. Both files will in our package.</p><h4>js/script.js</h4><pre class="brush:js">
var gl; // global WebGL object
var shaderProgram;

function initGL(canvas) {
    try {
        gl = canvas.getContext('experimental-webgl');
        gl.viewportWidth = canvas.width;
        gl.viewportHeight = canvas.height;
    } catch (e) {}
    if (! gl) {
        alert('Can`t initialise WebGL, not supported');
    }
}

function getShader(gl, type) {
    var str = '';
    var shader;

    if (type == 'x-fragment') {
        str = &quot;#ifdef GL_ES\n&quot;+
&quot;precision highp float;\n&quot;+
&quot;#endif\n&quot;+
&quot;varying vec4 vColor;\n&quot;+
&quot;void main(void) {\n&quot;+
&quot;    gl_FragColor = vColor;\n&quot;+
&quot;}\n&quot;;
        shader = gl.createShader(gl.FRAGMENT_SHADER);
    } else if (type == 'x-vertex') {
        str = &quot;attribute vec3 aVertexPosition;\n&quot;+
&quot;attribute vec4 aVertexColor;\n&quot;+
&quot;uniform mat4 uMVMatrix;\n&quot;+
&quot;uniform mat4 uPMatrix;\n&quot;+
&quot;varying vec4 vColor;\n&quot;+
&quot;void main(void) {\n&quot;+
&quot;    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n&quot;+
&quot;    vColor = aVertexColor;\n&quot;+
&quot;}\n&quot;;
        shader = gl.createShader(gl.VERTEX_SHADER);
    } else {
        return null;
    }

    gl.shaderSource(shader, str);
    gl.compileShader(shader);

    if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
        alert(gl.getShaderInfoLog(shader));
        return null;
    }
    return shader;
}

function initShaders() {
    var fragmentShader = getShader(gl, 'x-fragment');
    var vertexShader = getShader(gl, 'x-vertex');

    shaderProgram = gl.createProgram();
    gl.attachShader(shaderProgram, vertexShader);
    gl.attachShader(shaderProgram, fragmentShader);
    gl.linkProgram(shaderProgram);

    if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
        alert('Can`t initialise shaders');
    }

    gl.useProgram(shaderProgram);

    shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, 'aVertexPosition');
    gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);

    shaderProgram.vertexColorAttribute = gl.getAttribLocation(shaderProgram, 'aVertexColor');
    gl.enableVertexAttribArray(shaderProgram.vertexColorAttribute);

    shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, 'uPMatrix');
    shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, 'uMVMatrix');
}

var mvMatrix = mat4.create();
var mvMatrixStack = [];
var pMatrix = mat4.create();

function mvPushMatrix() {
    var copy = mat4.create();
    mat4.set(mvMatrix, copy);
    mvMatrixStack.push(copy);
}

function mvPopMatrix() {
    if (mvMatrixStack.length == 0) {
        throw 'Invalid popMatrix!';
    }
    mvMatrix = mvMatrixStack.pop();
}

function setMatrixUniforms() {
    gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);
    gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);
}

function degToRad(degrees) {
    return degrees * Math.PI / 180;
}

var objVertexPositionBuffer;
var objVertexColorBuffer;

function initObjBuffers() {
    objVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, objVertexPositionBuffer);
    var vertices = [
         1.0,  2.0,  -1.0,
        -1.0,  2.0,  -1.0,
         1.0, -2.0,  -1.0,
        -1.0, -2.0,  -1.0,
         1.0,  2.0,  1.0,
        -1.0,  2.0,  1.0,
         1.0, -2.0,  1.0,
        -1.0, -2.0,  1.0,
    ];
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
    objVertexPositionBuffer.itemSize = 3;
    objVertexPositionBuffer.numItems = 8;

    objVertexColorBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, objVertexColorBuffer);
    var colors = [
        1.0, 0.0, 0.0, 1.0,
        0.0, 1.0, 0.0, 0.5,
        0.0, 1.0, 0.0, 1.0,
        0.0, 0.0, 1.0, 1.0,
        0.0, 0.0, 1.0, 1.0,
        0.0, 1.0, 0.0, 1.0,
        0.0, 1.0, 0.0, 0.5,
        1.0, 0.0, 0.0, 1.0,
    ];
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);
    objVertexColorBuffer.itemSize = 4;
    objVertexColorBuffer.numItems = 8;
}

var iObjDeg = 0;

function drawScene() {
    gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

    mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix);

    mat4.identity(mvMatrix);

    mat4.translate(mvMatrix, [0.0, 0.0, -10.0]);

    mvPushMatrix();
    mat4.rotate(mvMatrix, degToRad(iObjDeg), [1, 1, 1]);

    gl.bindBuffer(gl.ARRAY_BUFFER, objVertexPositionBuffer);
    gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, objVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);

    gl.bindBuffer(gl.ARRAY_BUFFER, objVertexColorBuffer);
    gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, objVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0);

    setMatrixUniforms();
    gl.drawArrays(gl.TRIANGLE_STRIP, 0, objVertexPositionBuffer.numItems);

    mvPopMatrix();
}

function drawFrame() {
    requestAnimFrame(drawFrame);
    drawScene();

    iObjDeg += 3; // 3 degrees per frame
}

function initWebGl() {
    var canvas = document.getElementById('panel');

    initGL(canvas);
    initShaders()
    initObjBuffers();

    gl.clearColor(1.0, 0.5, 0.3, 1.0);
    gl.enable(gl.DEPTH_TEST);

    drawFrame();
}
</pre><p>Pretty big code, isn`t it? but anyway &#8211; here are all necessary to draw our demo. Since page loaded &#8211; we performing few initializations (initGL, initShaders, initObjBuffers functions), then we defining color for our scene (via gl.clearColor), and after &#8211; drawing our scene (drawFrame function). In this function we using &#8216;requestAnimFrame&#8217; to define function which will calling periodically when WebGL will need to draw next frame.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Making 3D WebGL demonstration - demo 139" href="http://www.script-tutorials.com/demos/139/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Making 3D WebGL demonstration - demo 139" href="http://www.script-tutorials.com/demos/139/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Not bad, isn`t it? Possible today we made first step to next generation. And possible that in coming future we will start a series of articles related with game development with HTML5. Welcome back!</p><div
class="shr-publisher-995"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/webgl-box-photo-slideshow/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/174/thumb.png" alt="Creating a 3D Animated Box HTML5 WebGL Photo Slideshow" /> <br
/> Creating a 3D Animated Box HTML5 WebGL Photo Slideshow</a></li><li> <a
href="http://www.script-tutorials.com/twisting-images-webgl/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/144/thumb.png" alt="Creating a Keyboard Sensitive 3D Twisted Images in WebGl" /> <br
/> Creating a Keyboard Sensitive 3D Twisted Images in WebGl</a></li><li> <a
href="http://www.script-tutorials.com/creating-photo-array-in-webgl/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/165/thumb.png" alt="Creating a Photo Array in WebGL" /> <br
/> Creating a Photo Array in WebGL</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/making-3d-webgl-demonstration/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Creating Cross-browser Compatible Wave Effects Using Javascript</title><link>http://www.script-tutorials.com/cross-browser-effect-of-waves-using-javascript/</link> <comments>http://www.script-tutorials.com/cross-browser-effect-of-waves-using-javascript/#comments</comments> <pubDate>Tue, 24 May 2011 17:34:09 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[compatible]]></category> <category><![CDATA[cross browser]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[wave]]></category> <category><![CDATA[wave effects]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=665</guid> <description><![CDATA[Cross-browser effect of waves using javascript Today&#8217;s lesson quite entertaining, we&#8217;ll learn how to construct a wave effect. For clarity, we will apply that effect to the picture. I will explain how it works directly in our tutorial, now, its time to see our online demonstration. Here are samples and downloadable package: Live Demo download [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/flare-lens/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/89/thumb.png" alt="How to Create Cross Browser Compatible Flare Lens Effect using Javascript" /> How to Create Cross Browser Compatible Flare Lens Effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/71/thumb.png" alt="Cross-browser Supported Image Skew effect using Javascript" /> Cross-browser Supported Image Skew effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/custom-scrollbars-cross-browser-solution/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/95/thumb.png" alt="Custom scrollbars &#8211; cross-browser solution" /> Custom scrollbars &#8211; cross-browser solution</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Crossbrowser wave effect" alt="Crossbrowser wave effect" src="http://www.script-tutorials.com/demos/81/thumb.png"></div><p><strong>Cross-browser effect of waves using javascript</strong><br
/> <br
/>Today&#8217;s lesson quite entertaining, we&#8217;ll learn how to construct a wave effect. For clarity, we will apply that effect to the picture. I will explain how it works directly in our tutorial, now, its time to see our online demonstration.<br
/> <span
id="more-665"></span></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Cross-browser effect of waves - demo 81" href="http://www.script-tutorials.com/demos/81/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cross-browser effect of waves - demo 81" href="http://www.script-tutorials.com/demos/81/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>As usual, we start with the HTML. This is source code of our sample:</p><h4>index.html</h4><pre class="brush:html">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Effect of waves using pure JavaScript&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/main.css&quot; /&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
 &lt;body&gt;
    &lt;div class=&quot;example&quot;&gt;
        &lt;div id=&quot;main_object&quot;&gt;
            &lt;img id=&quot;source_img&quot; src=&quot;image.jpg&quot;&gt;
            &lt;div id=&quot;wave_zone&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre><p>Here are prepared object, with 2 elements inside &#8211; image itself and bottom area for waving effect</p><h3>Step 2. CSS</h3><p>Here are single CSS file with all necessary styles:</p><h4>css/main.css</h4><pre class="brush:css">
body{background:#eee;margin:0;padding:0}
.example{background:#FFF;width:800px;border:1px #000 solid;margin:20px auto;padding:15px;-moz-border-radius: 3px;-webkit-border-radius: 3px}

#main_object {
    position: relative;
}
#main_object img {
    display: block;
}
#main_object #wave_zone img {
    position:absolute;
    left:-9999px;
}
#main_object span {
    position:absolute;
    font-size:0px;
}
#main_object #wave_zone {
    position:relative;
    display:block;
    overflow:hidden;
    background-color:#000;
}
</pre><h3>Step 3. JS</h3><p>Here are our main Javascript:</p><h4>js/main.js</h4><pre class="brush:js">
// wave sub objects
function WSubObj(num, img, object, iwidth, iheight){
    this.S = num;
    var o = document.createElement(&quot;span&quot;);
    o.style.overflow = &quot;hidden&quot;;
    o.style.width = iwidth + &quot;px&quot;;
    o.style.height = iheight + &quot;px&quot;;
    o.style.top = (num-1) + &quot;px&quot;;
    var oI = document.createElement(&quot;img&quot;);
    oI.src = img.src;
    oI.style.left = &quot;0px&quot;;
    oI.style.top = (-iheight + num) + &quot;px&quot;;
    oI.style.width = iwidth + &quot;px&quot;;
    oI.style.height = iheight + &quot;px&quot;;
    o.appendChild(oI);
    document.getElementById(&quot;wave_zone&quot;).appendChild(o);
    this.spa = o.style;
    this.ddx = 0
    this.PX  = 0
    this.x   = 0
    if (num &gt; 0) this.prev = object[num - 1];
}

WSubObj.prototype.main = function(power){
    var x0 = (this.S == 0) ? Math.random() * power : this.prev.x;
    this.x = this.PX += (this.ddx += ( (x0 - this.PX - this.ddx) * 2 ) / 2.8) / 1.4;
    this.spa.left = Math.round(this.x) + &quot;px&quot;;
}

// wave effect object
var weff = {
    // variables
    power : 2.2,

    // inner variables
    object : new Array(),
    simg : null,
    iwidth  : 0,
    iheight  : 0,

    // initialization function
    init : function() {
        for (var i = 0; i &lt; this.iheight/4; i++)
            this.object[i] = new WSubObj(i, this.simg, this.object, this.iwidth, this.iheight);
    },

    // main loop function of water effect
    run : function() {
        var i = 0, o;
        while (o = weff.object[i++]) o.main(weff.power);
        setTimeout(weff.run, 40);
    }
};

// on page load
window.onload = function() {
    weff.simg = document.getElementById(&quot;source_img&quot;);
    weff.iwidth = weff.simg.width;
    weff.iheight = weff.simg.height;

    // set necessary width and height for wave zone element
    var css = document.getElementById(&quot;wave_zone&quot;).style;
    css.height = (weff.iheight/4 - 1) + &quot;px&quot;;
    css.width  = weff.iwidth + &quot;px&quot;;

    weff.init();
    weff.run();
}
</pre><p>It is rather simple. When the page loads &#8211; I initialize our main object, and create multiple subimages (in spans) for each row of second half of our sample, then, periodically gently increase the amplitude of oscillations. So, in result &#8211; we can see effect of waves.</p><h3>Step 4. Images</h3><p>For our demo I used only one image:</p><p><img
alt="img_01" src="http://www.script-tutorials.com/demos/81/image.jpg" width="585" height="363" /></p><hr
/><h5 style="text-align: center;"><strong><a
title="Cross-browser effect of waves - demo 81" href="http://www.script-tutorials.com/demos/81/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cross-browser effect of waves - demo 81" href="http://www.script-tutorials.com/demos/81/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today I told you how to create easy wave effect to images. You always can play with different variables of this demo ot archive different funny results. Hope our javascript lessons still interesting for you. Good luck!</p><div
class="shr-publisher-665"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/flare-lens/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/89/thumb.png" alt="How to Create Cross Browser Compatible Flare Lens Effect using Javascript" /> <br
/> How to Create Cross Browser Compatible Flare Lens Effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/71/thumb.png" alt="Cross-browser Supported Image Skew effect using Javascript" /> <br
/> Cross-browser Supported Image Skew effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/custom-scrollbars-cross-browser-solution/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/95/thumb.png" alt="Custom scrollbars &#8211; cross-browser solution" /> <br
/> Custom scrollbars &#8211; cross-browser solution</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/cross-browser-effect-of-waves-using-javascript/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>How to use Multiple backgrounds and Animation with CSS3</title><link>http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/</link> <comments>http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/#comments</comments> <pubDate>Tue, 17 May 2011 18:25:12 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[backgroudn]]></category> <category><![CDATA[css3]]></category> <category><![CDATA[html]]></category> <category><![CDATA[images]]></category> <category><![CDATA[multiple background images]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=640</guid> <description><![CDATA[Multiple backgrounds with CSS3 and a little of animation In CSS3 appear new possibility to use multiple backgrounds for the objects, in our new article I will demonstrate how to do it. And, I going to add a bit of JS code for simple animation (to make it not so boring). Commonly, it is very [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/positioning-background-with-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/2/bg.jpg" alt="Positioning Backgrounds with Jquery" /> Positioning Backgrounds with Jquery</a></li><li> <a
href="http://www.script-tutorials.com/importing-multiple-rss-feeds-using-newswidget-jquery/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="Importing multiple RSS feeds &#8211; using newsWidget (jQuery)" /> Importing multiple RSS feeds &#8211; using newsWidget (jQuery)</a></li><li> <a
href="http://www.script-tutorials.com/how-to-do-pure-css3-photo-gallery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/171/thumb.png" alt="How to Create a Pure CSS3 Animated Photo Gallery" /> How to Create a Pure CSS3 Animated Photo Gallery</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Multiple backgrounds with CSS3 with animation" alt="Multiple backgrounds with CSS3 with animation" src="http://www.script-tutorials.com/demos/76/thumb.png"></div><p><strong>Multiple backgrounds with CSS3 and a little of animation</strong><br
/> <br
/> In CSS3 appear new possibility to use multiple backgrounds for the objects, in our new article I will demonstrate how to do it. And, I going to add a bit of JS code for simple animation (to make it not so boring). Commonly, it is very easy to apply multiple backgrounds &#8211; we just need to list them (separated by commas) in the object properties.<br
/> <span
id="more-640"></span></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Multiple backgrounds, CSS3 and animation - demo 76" href="http://www.script-tutorials.com/demos/76/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Multiple backgrounds, CSS3 and animation - demo 76" href="http://www.script-tutorials.com/demos/76/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>As usual, we start with the HTML. This is source code of our sample:</p><h4>index.html</h4><pre class="brush:html">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Multiple backgrounds with CSS3 and a little of animation&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/main.css&quot; /&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
 &lt;body&gt;
    &lt;div class=&quot;example&quot;&gt;
        &lt;div id=&quot;main_object&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre><p>Nothing special, just &lt;div id=&quot;main_object&quot;&gt;&lt;/div&gt; inside</p><h3>Step 2. CSS</h3><p>Here are single CSS file with all necessary styles:</p><h4>css/main.css</h4><pre class="brush:css">
body{background:#eee;margin:0;padding:0}
.example{background:#FFF;width:950px;border:1px #000 solid;margin:20px auto;padding:15px;-moz-border-radius: 3px;-webkit-border-radius: 3px}

#main_object{
    position:relative;width:950px;height:700px;overflow:hidden;cursor:pointer;
    background-image: url(../images/layer1.png), url(../images/layer2.png), url(../images/layer3.png), url(../images/bg.jpg);
    background-position: center bottom, right top, right bottom, left top;
    background-repeat: no-repeat;
}
</pre><p>Here, you can see way how I pointing these several backgrounds to our main element &#8211; all comma separated. Same and for &#8216;background-position&#8217; too. Of course, if you want &#8211; you always can use use &#8216;background&#8217; property to set all necessary styles, in this case &#8211; you can enum your properties in same way, separating values with commas, example:</p><pre class="brush:css">
background: url(../images/layer1.png) no-repeat center bottom, url(../images/layer2.png) no-repeat right top, url(../images/layer3.png) no-repeat right bottom, url(../images/bg.jpg) no-repeat left top;
}
</pre><h3>Step 3. JS</h3><p>Here are a little of JS for our animation:</p><h4>js/main.js</h4><pre class="brush:js">
var ex76 = {
    // variables
    l1w  : 358, // layer 1 width
    l1h  : 235, // layer 1 height
    l2w  : 441, // layer 2 width
    l3w  : 307, // layer 3 width

    // inner variables
    obj  : 0,
    xm   : 0,
    ym   : 0,
    x1 : 0,
    y1 : 0,
    x2 : 0,
    x3 : 0,

    // initialization
    init : function() {
        this.obj = document.getElementById('main_object');

        this.x2 = this.obj.clientWidth;
        this.x3 = -this.l3w;

        this.run();
    },

    // refreshing mouse positions
    mousemove : function(e) {
        this.xm = e.clientX;
        this.ym = e.clientY;

        // recalculation new positions
        this.x1 = this.xm - this.obj.offsetLeft - ex76.l1w/2;
        this.y1 = this.ym - this.obj.offsetTop - ex76.l1h/2;
    },

    // loop function
    run : function() {
        // shifting second layer object to left
        ex76.x2--;
        if (ex76.x2 &lt; -ex76.l2w) ex76.x2 = ex76.obj.clientWidth;

        // shifting second layer object to right
        ex76.x3++;
        if (ex76.x3 &gt; ex76.obj.clientWidth) ex76.x3 = -ex76.l3w;

        // updating background-position value with new positions
        ex76.obj.style.backgroundPosition = ex76.x1 + 'px ' + ex76.y1 + ', ' + ex76.x2 + 'px top, ' + ex76.x3 + 'px bottom, left top';

        // loop
        setTimeout(ex76.run, 20);
    }
};

window.onload = function() {
    ex76.init(); // initialization

    // binding mouse move event
    document.onmousemove = function(e) {
        if (window.event)
            e = window.event;
        ex76.mousemove(e);
    }
}
</pre><p>This is pretty easy &#8211; for second and third layer &#8211; I changing its X positions (by cycle), for first layer &#8211; I changing its position in place where located our mouse.</p><h3>Step 4. Images</h3><p>Also we need several images for our demo (for different layers):</p><pre class="sources">
    <img src="http://www.script-tutorials.com/demos/76/images/bg.jpg" alt="bg.jpg" style="width: 550px;" />
    <img src="http://www.script-tutorials.com/demos/76/images/layer1.png" alt="layer1.png" />
    <img src="http://www.script-tutorials.com/demos/76/images/layer2.png" alt="layer2.png" />
    <img src="http://www.script-tutorials.com/demos/76/images/layer3.png" alt="layer3.png" />
</pre><hr
/><h5 style="text-align: center;"><strong><a
title="Multiple backgrounds, CSS3 and animation - demo 76" href="http://www.script-tutorials.com/demos/76/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Multiple backgrounds, CSS3 and animation - demo 76" href="http://www.script-tutorials.com/demos/76/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today I told you how you can assign several images as background for single element. Hope that our demo gave you some ideas. Here are another application of this, you can create custom controls (buttons as example) with custom background, as example rounded buttons. You will need just set 2-3 layers (for beginning, center and end of button). Good luck!</p><div
class="shr-publisher-640"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/positioning-background-with-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/2/bg.jpg" alt="Positioning Backgrounds with Jquery" /> <br
/> Positioning Backgrounds with Jquery</a></li><li> <a
href="http://www.script-tutorials.com/importing-multiple-rss-feeds-using-newswidget-jquery/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="Importing multiple RSS feeds &#8211; using newsWidget (jQuery)" /> <br
/> Importing multiple RSS feeds &#8211; using newsWidget (jQuery)</a></li><li> <a
href="http://www.script-tutorials.com/how-to-do-pure-css3-photo-gallery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/171/thumb.png" alt="How to Create a Pure CSS3 Animated Photo Gallery" /> <br
/> How to Create a Pure CSS3 Animated Photo Gallery</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>How to Create Animated Photo Gallery using jQuery (Slider Kit)</title><link>http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/</link> <comments>http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/#comments</comments> <pubDate>Wed, 11 May 2011 17:48:59 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[jQuery]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[animated]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[photo gallery]]></category> <category><![CDATA[slider kit]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=616</guid> <description><![CDATA[How to create photo gallery using Slider Kit (jQuery) Today we will continue overviews of available photo galleries. Next gallery will Slider Kit. This is free jQuery photo gallery. This gallery have 4 different views (standard, with captions, vertical and minimalistic). Important notes &#8211; that it compatible with all browsers (this can work even in [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-photo-gallery-using-smartgallery-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/77/thumb.png" alt="Creating an Attractive Photo Gallery using SmartGallery (jQuery)" /> Creating an Attractive Photo Gallery using SmartGallery (jQuery)</a></li><li> <a
href="http://www.script-tutorials.com/how-to-do-pure-css3-photo-gallery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/171/thumb.png" alt="How to Create a Pure CSS3 Animated Photo Gallery" /> How to Create a Pure CSS3 Animated Photo Gallery</a></li><li> <a
href="http://www.script-tutorials.com/animated-photo-gallery-grid-with-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/54/thumb.png" alt="Animated Photo Gallery (grid) with javascript" /> Animated Photo Gallery (grid) with javascript</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Slider Kit photo gallery" alt="Slider Kit photo gallery" src="http://www.script-tutorials.com/demos/72/thumb.png"></div><p><strong>How to create photo gallery using Slider Kit (jQuery)</strong><br
/> <br
/>Today we will continue overviews of available photo galleries. Next gallery will <a
rel="nofollow" href="http://www.kyrielles.net/sliderkit/">Slider Kit</a>. This is free jQuery photo gallery. This gallery have 4 different views (standard, with captions, vertical and minimalistic). Important notes &#8211; that it compatible with all browsers (this can work even in IE6) and have very light weight (packed version of library less 8kb). You can navigate through images using your mouse, mouse wheel, and even keyboard. The result &#8211; we will have a beautiful gallery with an intuitive interface. Today I will tell you about how to implement this gallery (you even will able to use this in any CMS as gallery of your member&#8217;s photos).<br
/> <br
/>By default this gallery expect already prepared html data (with all images and thumbs). So it can be difficult to load dinamic content in it (different photos of different members). But its ok, we will force loading of necessary images when page finish loading using jQuery (we will load our images dinamically, using $.get function). We will use PHP to generate lists of necessary images and thumbs.<br
/> <span
id="more-616"></span></p><p>Ok, lets start, and lets check prepared demos and download ready package:</p><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - demo 1" href="http://www.script-tutorials.com/demos/72/index.html" target="_blank">Live Demo 1</a></strong></h5><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - demo 2" href="http://www.script-tutorials.com/demos/72/index2.html" target="_blank">Live Demo 2</a></strong></h5><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - demo 3" href="http://www.script-tutorials.com/demos/72/index3.html" target="_blank">Live Demo 3</a></strong></h5><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - package" href="http://www.script-tutorials.com/demos/72/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>As usual, we start with the HTML. This is source code of our sample:</p><h4>index.html</h4><pre class="brush:html">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/sliderkit-core.css&quot; media=&quot;screen, projection&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/sliderkit-demos.css&quot; media=&quot;screen, projection&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;css/main.css&quot; type=&quot;text/css&quot; /&gt;
&lt;!--[if IE 6]&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/sliderkit-demos-ie6.css&quot; /&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 7]&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/sliderkit-demos-ie7.css&quot; /&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 8]&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/sliderkit-demos-ie8.css&quot; /&gt;
&lt;![endif]--&gt;

&lt;script src=&quot;js/jquery-1.5.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.sliderkit.1.5.1.pack.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.easing.1.3.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.mousewheel.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/main.js&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;example&quot;&gt;
    &lt;h3&gt;&lt;a href=&quot;#&quot;&gt;Slider Kit example&lt;/a&gt;&lt;/h3&gt;

    &lt;div class=&quot;sliderkit photosgallery-std&quot; id=&quot;sliderkit_galery&quot;&gt;
        &lt;div class=&quot;sliderkit-nav&quot;&gt;
            &lt;div class=&quot;sliderkit-nav-clip&quot;&gt;
                &lt;ul&gt;&lt;/ul&gt;
            &lt;/div&gt;
            &lt;div class=&quot;sliderkit-btn sliderkit-nav-btn sliderkit-nav-prev&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;#&quot; title=&quot;Previous line&quot;&gt;&lt;span&gt;Previous line&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
            &lt;div class=&quot;sliderkit-btn sliderkit-nav-btn sliderkit-nav-next&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;#&quot; title=&quot;Next line&quot;&gt;&lt;span&gt;Next line&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
            &lt;div class=&quot;sliderkit-btn sliderkit-go-btn sliderkit-go-prev&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;#&quot; title=&quot;Previous photo&quot;&gt;&lt;span&gt;Previous photo&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
            &lt;div class=&quot;sliderkit-btn sliderkit-go-btn sliderkit-go-next&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;#&quot; title=&quot;Next photo&quot;&gt;&lt;span&gt;Next photo&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;sliderkit-panels&quot;&gt;
            &lt;div class=&quot;sliderkit-btn sliderkit-go-btn sliderkit-go-prev&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;#&quot; title=&quot;Previous&quot;&gt;&lt;span&gt;Previous&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
            &lt;div class=&quot;sliderkit-btn sliderkit-go-btn sliderkit-go-next&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;#&quot; title=&quot;Next&quot;&gt;&lt;span&gt;Next&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre><p>You can notice, that currently we have empty UL inside &#8216;sliderkit-nav&#8217;. We will load its units on &#8216;jQuery(window).load&#8217; event. Also, by default &#8216;sliderkit-panels&#8217; should contain ready set of images too, we will load it after too. So currently we just prepared skeleton &#8211; interface elements (panels and buttons).</p><p><strong>Now, make attention to class of our main gallery &#8216;photosgallery-std&#8217;. This class will determinate gallery view. For first example we using Standard view (&#8216;photosgallery-std&#8217;, where &#8216;std&#8217; &#8211; Standard shortly). Here are another possible classes: &#8216;photosgallery-captions&#8217; (will display custom captions at images), &#8216;photosgallery-vertical&#8217; (will display captions and make gallery vertically) and &#8216;photosgallery-minimalistic&#8217; (minimalistic set, nothing). Another point, no need generate navigation buttons in case if you going to use &#8216;minimalistic&#8217;, they don`t will display anyway <img
src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p><p>In our package you will find &#8216;index2.html&#8217; and also &#8216;index3.html&#8217;. This is just different gallery views.</p><h3>Step 2. CSS</h3><p>Here are used CSS files:</p><h4>css/main.css</h4><pre class="brush:css">
body{background:#eee;font-family:Verdana, Helvetica, Arial, sans-serif;margin:0;padding:0}
.example{background:#FFF;width:500px;border:1px #000 solid;margin:20px auto;padding:15px;-moz-border-radius: 3px;-webkit-border-radius: 3px}
</pre><p>As usual &#8211; our main file for demo layout &#8211; very easy. But of course, pur new gallery have own css files:</p><h4>css/sliderkit-core.css, css/sliderkit-demos-ie6.css, css/sliderkit-demos-ie7.css, css/sliderkit-demos-ie8.css and css/sliderkit-demos.css</h4><p>All these files you will able to find in package (they are large enough to include them in the article)</p><h3>Step 3. JS</h3><p>Here are all JS files:</p><h4>js/main.js</h4><pre class="brush:js">
//jQuery(window).load() must be used instead of jQuery(document).ready() because of Webkit compatibility
jQuery(window).load(function() {
    $.get('feed.php', function(data){
        $('.sliderkit-nav-clip ul').append(data.thumbs);
        $('.sliderkit-panels').append(data.images);

        jQuery('#sliderkit_galery').sliderkit({
            mousewheel:true,
            keyboard:true,
            shownavitems:4,
            panelbtnshover:true,
            auto:true,
            circular:true,
            navscrollatend:true
        });
    });
});
</pre><p>So, when page loaded, I start loading extra info (about using thumbs and images) from feed.php using jQuery. After, appending received info (JSON) to the pending objects. And then &#8211; perform initialization of our gallery with necessary params. First demo will using mousewheel, keyboard, will display 4 elements in navigation, have auto scrolling. Full list of possible option I will put in end of article. Next file<br
/><h4>js/main2.js</h4><p> have similar structure, but another set of properties:</p><pre class="brush:js">
jQuery(window).load(function() {
    $.get('feed.php', function(data){
        $('.sliderkit-nav-clip ul').append(data.thumbs);
        $('.sliderkit-panels').append(data.images);

        jQuery('#sliderkit_galery').sliderkit({
            mousewheel:true,
            keyboard:true,
            shownavitems:4,
            auto:true,
            circular:true,
            navscrollatend:true,
            verticalnav:true,
            navclipcenter:true,
            navitemshover:true,
            panelfxspeed: 2000
        });
    });
});
</pre><p>And here are code for our third sample:</p><h4>js/main3.js</h4><pre class="brush:js">
jQuery(window).load(function() {
    $.get('feed.php', function(data){
        $('.sliderkit-nav-clip ul').append(data.thumbs);
        $('.sliderkit-panels').append(data.images);

        jQuery('#sliderkit_galery').sliderkit({
            mousewheel:true,
            keyboard:true,
            shownavitems:4,
            auto:true,
            circular:true,
            navscrollatend:true
        });
    });
});
</pre><h4>js/jquery-1.5.2.min.js, js/jquery.easing.1.3.min.js, js/jquery.mousewheel.min.js and js/jquery.sliderkit.1.5.1.pack.js</h4><p>This is list of all another used JS files (jquery library with gallery). Available in our package.</p><h3>Step 4. PHP</h3><p>Here are source code of our generator of images:</p><h4>feed.php</h4><pre class="brush:php">
&lt;?

$sThumbTemplate = &lt;&lt;&lt;HTML
&lt;li&gt;&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot; title=&quot;{title}&quot;&gt;&lt;img src=&quot;{fileurl}&quot; alt=&quot;{title}&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
HTML;

$sImageTemplate = &lt;&lt;&lt;HTML
&lt;div class=&quot;sliderkit-panel&quot;&gt;
    &lt;img src=&quot;{fileurl}&quot; alt=&quot;{title}&quot; /&gt;
    &lt;div class=&quot;sliderkit-panel-textbox&quot;&gt;
        &lt;div class=&quot;sliderkit-panel-text&quot;&gt;
            &lt;h4&gt;{title}&lt;/h4&gt;
            &lt;p&gt;{description}&lt;/p&gt;
        &lt;/div&gt;
        &lt;div class=&quot;sliderkit-panel-overlay&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
HTML;

$sThumbs = $sImages = '';
$sFolder = 'data_images/';

$aUnits = array(
    'pic1.jpg' =&gt; 'Image 1', 'pic2.jpg' =&gt; 'Image 2', 'pic3.jpg' =&gt; 'Image 3', 'pic4.jpg' =&gt; 'Image 4',
    'pic5.jpg' =&gt; 'Image 5', 'pic6.jpg' =&gt; 'Image 6', 'pic7.jpg' =&gt; 'Image 7', 'pic8.jpg' =&gt; 'Image 8',
    'pic9.jpg' =&gt; 'Image 9', 'pic10.jpg' =&gt; 'Image 10'
);
foreach ($aUnits as $sFileName =&gt; $sTitle) {
    $sThumbs .= strtr($sThumbTemplate, array('{fileurl}' =&gt; $sFolder . 't_' . $sFileName, '{title}' =&gt; $sTitle));
    $sImages .= strtr($sImageTemplate, array('{fileurl}' =&gt; $sFolder . $sFileName, '{title}' =&gt; $sTitle, '{description}' =&gt; $sTitle . ' photo description here'));
}

header(&quot;Content-Type: application/json&quot;);
require_once('Services_JSON.php');
$oJson = new Services_JSON();
echo $oJson-&gt;encode(array('thumbs' =&gt; $sThumbs, 'images' =&gt; $sImages));

?&gt;
</pre><p>Firstly, I defined 2 templates which going to use for generation of necessary info about using images and for thumbs and for images. Also will use JSON to be able to send both strings in one time (inside array). All our custom images located in &#8216;data_images&#8217; directory. All thumbs &#8211; have prefix &#8216;t_&#8217;. Easy enough <img
src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><h3>Step 5. Images</h3><p>Our Slider Kit gallery using next images:</p><p><img
src="arrows-h-black.gif" alt="" /><br
/> <img
src="arrows-h.png" alt="" /><br
/> <img
src="arrows-v-black.gif" alt="" /><br
/> <img
src="arrows-v.png" alt="" /><br
/> <img
src="slider-arrow-left.gif" alt="" /><br
/> <img
src="slider-arrow-right.gif" alt="" /></p><h3>And at last &#8211; table with all possible params (to current moment) of this gallery:</h3><table
class="info" cellspacing="0" cellpadding="0" border="1"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td>cssprefix</td><td>string</td><td>sliderkit</td><td>The prefix to use on every CSS class names</td></tr><tr><td>start</td><td>int</td><td>0</td><td>Set the start position. First is 0.</td></tr><tr><td>auto</td><td>boolean</td><td>true</td><td>Activate auto-scrolling</td></tr><tr><td>autospeed</td><td>int</td><td>4000</td><td>Set the auto-scrolling speed (ms)</td></tr><tr><td>mousewheel</td><td>boolean</td><td>false</td><td>Activate the mousewheel navigation</td></tr><tr><td>keyboard</td><td>boolean</td><td>false</td><td>Activate the keyboard navigation. Very basic for now (left/right arrows only)</td></tr><tr><td>panelclick</td><td>boolean</td><td>false</td><td>Activate the 1-click navigation</td></tr><tr><td>circular</td><td>boolean</td><td>false</td><td>Activate the infinite nav scroll</td></tr><tr><td>shownavitems</td><td>int</td><td>5</td><td>Defines how many thumbnails to display in the nav clip</td></tr><tr><td>navitemshover</td><td>boolean</td><td>false</td><td>If set the panels will slide on nav thumbnails mouseover (by default panels slide on click)</td></tr><tr><td>navclipcenter</td><td>boolean</td><td>false</td><td>Defines if the nav clip must be center-aligned in the nav container</td></tr><tr><td>navcontinuous</td><td>boolean</td><td>false</td><td>If set to true, will make the carousel scroll continuously (use this option with a &#8220;linear&#8221; scrolleasing)</td></tr><tr><td>navscrollatend</td><td>boolean</td><td>false</td><td>If set to &#8216;true&#8217;, will make the carousel scroll if a line first or last thumbnail is clicked</td></tr><tr><td>navfx</td><td>string</td><td>sliding</td><td>Define the carousel transition effect. Possible values: &#8220;sliding&#8221;, &#8220;none&#8221;</td></tr><tr><td>scroll</td><td>int</td><td>equal to &#8216;shownavitems&#8217; option value</td><td>Defines how many nav thumbnails must be scrolled when nav buttons are clicked. Can&#8217;t be greater than the &#8216;shownavitems&#8217; option value</td></tr><tr><td>scrollspeed</td><td>int</td><td>600</td><td>Set the nav scroll speed (ms)</td></tr><tr><td>scrolleasing</td><td>string</td><td>swing</td><td>Add an easing effect to the nav slide transition. Default jQuery easing functions are &#8220;swing&#8221; or &#8220;linear&#8221;.</td></tr><tr><td>swing</td><td>string</td><td>fading</td><td>Define the panels transition effect. Possible values: &#8220;fading&#8221;, &#8220;sliding&#8221;, &#8220;none&#8221;</td></tr><tr><td>panelfxspeed</td><td>int</td><td>700</td><td>Set the panel slide transition effect speed (ms)</td></tr><tr><td>panelfxeasing</td><td>string</td><td>swing</td><td>Add an easing effect to the panel slide transition. Default jQuery easing functions are &#8220;swing&#8221; or &#8220;linear&#8221;</td></tr><tr><td>panelfxfirst</td><td>string</td><td>none</td><td>Add a transition effect on the first displayed item. There are only 2 possible values for the moment: &#8220;fading&#8221; or &#8220;none&#8221;</td></tr><tr><td>panelfxbefore</td><td>function</td><td>function(){}</td><td>The function called before the panel transition start</td></tr><tr><td>panelfxafter</td><td>function</td><td>function(){}</td><td>The function called when panel transition is over</td></tr><tr><td>panelbtnshover</td><td>boolean</td><td>false</td><td>If set to true, go buttons will fade in/out on panel mouseover</td></tr><tr><td>verticalnav</td><td>boolean</td><td>false</td><td>Set the nav clip direction to vertical</td></tr><tr><td>verticalslide</td><td>boolean</td><td>false</td><td>Set the panel sliding direction to vertical (only if &#8220;panelfx&#8221; is defined as &#8220;sliding&#8221;)</td></tr><tr><td>tabs</td><td>boolean</td><td>false</td><td>Required to build a tabs menu</td></tr><tr><td>freeheight</td><td>boolean</td><td>false</td><td>Use panels with no fixed height (in this case, &#8216;panelfx&#8217; value can&#8217;t be &#8220;sliding&#8221;)</td></tr><tr><td>fastchange</td><td>boolean</td><td>true</td><td>By default the user can slide to the next content even if the slider is still running. You can stop this behavior by setting the &#8220;fastchange&#8221; option to false</td></tr><tr><td>debug</td><td>boolean</td><td>false</td><td>If set to true, the script will stop on errors and return error code values. Check documentation</td></tr></tbody></table><hr
/><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - demo 1" href="http://www.script-tutorials.com/demos/72/index.html" target="_blank">Live Demo 1</a></strong></h5><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - demo 2" href="http://www.script-tutorials.com/demos/72/index2.html" target="_blank">Live Demo 2</a></strong></h5><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - demo 3" href="http://www.script-tutorials.com/demos/72/index3.html" target="_blank">Live Demo 3</a></strong></h5><h5 style="text-align: center;"><strong><a
title="How to create photo gallery using Slider Kit - package" href="http://www.script-tutorials.com/demos/72/source.zip" target="_blank">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today I told you how to build new jQuery gallery, even several. Sure that you will happy to use it in your projects. Good luck!</p><div
class="shr-publisher-616"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-photo-gallery-using-smartgallery-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/77/thumb.png" alt="Creating an Attractive Photo Gallery using SmartGallery (jQuery)" /> <br
/> Creating an Attractive Photo Gallery using SmartGallery (jQuery)</a></li><li> <a
href="http://www.script-tutorials.com/how-to-do-pure-css3-photo-gallery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/171/thumb.png" alt="How to Create a Pure CSS3 Animated Photo Gallery" /> <br
/> How to Create a Pure CSS3 Animated Photo Gallery</a></li><li> <a
href="http://www.script-tutorials.com/animated-photo-gallery-grid-with-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/54/thumb.png" alt="Animated Photo Gallery (grid) with javascript" /> <br
/> Animated Photo Gallery (grid) with javascript</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Cross-browser Supported Image Skew effect using Javascript</title><link>http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/</link> <comments>http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/#comments</comments> <pubDate>Tue, 10 May 2011 17:34:12 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[effect]]></category> <category><![CDATA[image]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[shake]]></category> <category><![CDATA[skew]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=613</guid> <description><![CDATA[Cross-browser image shaking effect using javascript Today&#8217;s lesson quite entertaining, we&#8217;ll learn how to construct a shaking effect. For clarity, we will apply this effect to the picture. You will need to hold down by mouse a certain area in the image and move it to another location (drag). Now, I sure that better to [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/flare-lens/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/89/thumb.png" alt="How to Create Cross Browser Compatible Flare Lens Effect using Javascript" /> How to Create Cross Browser Compatible Flare Lens Effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/cross-browser-effect-of-waves-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/81/thumb.png" alt="Creating Cross-browser Compatible Wave Effects Using Javascript" /> Creating Cross-browser Compatible Wave Effects Using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/particles-in-water/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/51.png" alt="Creating Animated Particles in Water Effect using JavaScript" /> Creating Animated Particles in Water Effect using JavaScript</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Crossbrowser image shaking effect" alt="Crossbrowser image shaking effect" src="http://www.script-tutorials.com/demos/71/thumb.png"></div><p><strong>Cross-browser image shaking effect using javascript</strong><br
/> <br
/>Today&#8217;s lesson quite entertaining, we&#8217;ll learn how to construct a shaking effect. For clarity, we will apply this effect to the picture. You will need to hold down by mouse a certain area in the image and move it to another location (drag). Now, I sure that better to see our online demonstration. How did it achieve? In principle, simply enough, the entire &#8216;image&#8217; divided into 4 sectors. Place, where we will begin to drag by mouse &#8211; is the boundary separating of our four pictures. And shaking effect itself &#8211; will only change the sizes of our sectors and pictures in them. Read more.<br
/> <span
id="more-613"></span></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Cross-browser image shaking effect - demo 71" href="http://www.script-tutorials.com/demos/71/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cross-browser image shaking effect - demo 71" href="http://www.script-tutorials.com/demos/71/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>As usual, we start with the HTML. This is source code of our sample:</p><h4>index.html</h4><pre class="brush:html">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Image shaking effect using pure JavaScript&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/main.css&quot; /&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
 &lt;body&gt;
    &lt;div class=&quot;example&quot;&gt;
        &lt;div id=&quot;main_object&quot;&gt;
            &lt;div class=&quot;tl&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;image.jpg&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;tr&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;image.jpg&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;bl&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;image.jpg&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;br&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;image.jpg&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre><p>Here are main object with 4 images inside</p><h3>Step 2. CSS</h3><p>Here are single CSS file with all necessary styles:</p><h4>css/main.css</h4><pre class="brush:css">
body{background:#eee;margin:0;padding:0}
.example{background:#FFF;width:900px;border:1px #000 solid;margin:20px auto;padding:15px;-moz-border-radius: 3px;-webkit-border-radius: 3px}

#main_object{position:relative;width:900px;height:675px;overflow:hidden;cursor:pointer}
#main_object div{position:absolute;overflow:hidden}
#main_object img{position:absolute;-ms-interpolation-mode:nearest-neighbor}
#main_object .tl,#main_object .tl img{top:0;left:0}
#main_object .tr,#main_object .tr img{top:0;right:0}
#main_object .bl,#main_object .bl img{bottom:0;left:0}
#main_object .br,#main_object .br img{right:0;bottom:0}
</pre><h3>Step 3. JS</h3><p>Here are our main Javascript:</p><h4>js/main.js</h4><pre class="brush:js">
var ishk = {
    // variables
    speedD : .98, // degree of attenuation
    speedX : 50, // speed by X
    speedY : 60, // speed by X

    // inner variables
    xm   : 0,
    ym   : 0,
    sx   : 1,
    sy   : 1,
    svx  : 0,
    svy  : 0,
    xd   : 1,
    yd   : 1,
    drag : false,

    // initialization
    init : function() {
        // firstly we will pass through all inner div`s and its images and collect styles
        this.mobj = document.getElementById('main_object');
        var div = this.mobj.getElementsByTagName('div');
        this.d = [];
        this.i = [];
        for (var i = 0; i&lt;4; i++) {
            this.d[i] = div[i].style;
            this.i[i] = div[i].getElementsByTagName('img')[0].style;
        }

        // set initial params of our generated result
        this.resize();

        // prevent text selection in IE
        document.onselectstart = function() {
            return false;
        }
        // prevent IE from trying to drag an image
        this.mobj.ondrag = function() {
            return false;
        }
        // mouse down event, we will set 'drag flag to true, change cursor and positions
        this.mobj.onmousedown = function() {
            ishk.drag = true;
            ishk.mobj.style.cursor = 'move';
            ishk.xd = ishk.xm - ishk.nx;
            ishk.yd = ishk.ym - ishk.ny;
            return false;
        }
        // on mouse up - release 'drag' flag, change pointer
        document.onmouseup = function() {
            ishk.drag = false;
            ishk.mobj.style.cursor = 'pointer';
            return false;
        }
        // set max sizes to last image
        this.i[3].width =  ishk.nw;
        this.i[3].height = ishk.nh;
        // and initial positions too
        ishk.sx = ishk.nx;
        ishk.sy = ishk.ny;

        // start looping
        this.shake();
    },

    // refreshing mouse positions
    mousemove : function(e) {
        this.xm = e.clientX;
        this.ym = e.clientY;
    }, 

    // sub init of initial positions, plus, in case of window resizing - repeat too
    resize : function() {
        var o = ishk.mobj;
        for (ishk.nx = 0, ishk.ny = 0; o != null; o = o.offsetParent)
            ishk.nx += o.offsetLeft, ishk.ny += o.offsetTop;
        ishk.nw = ishk.mobj.offsetWidth;
        ishk.nh = ishk.mobj.offsetHeight;
    },

    // main shaking function
    shake : function() {
        // in case of mouse move and dragging - change center position
        if (ishk.drag) {
            ishk.sx = ishk.xm;
            ishk.sy = ishk.ym;
        } else { // otherwise - attenuation
            ishk.svx = ishk.speedD * ishk.svx - (ishk.sx - ishk.xd - ishk.nx) / ishk.speedX;
            ishk.svy = ishk.speedD * ishk.svy - (ishk.sy - ishk.yd - ishk.ny) / ishk.speedY;
            ishk.sx += ishk.svx;
            ishk.sy += ishk.svy;
        }

        // calculation new widths and heights of our div`s and images
        var w0 = Math.max(0, Math.round(ishk.sx) - ishk.nx);
        var h0 = Math.max(0, Math.round(ishk.sy) - ishk.ny);
        var w1 = Math.max(0, ishk.nw - (Math.round(ishk.sx) - ishk.nx));
        var h1 = Math.max(0, ishk.nh - (Math.round(ishk.sy) - ishk.ny));
        var w2 = Math.max(0, Math.round((w0 * ishk.nw) / ishk.xd));
        var h2 = Math.max(0, Math.round((h0 * ishk.nh) / ishk.yd));
        var w3 = Math.max(0, Math.round((w1 * ishk.nw) / (ishk.nw - ishk.xd)));
        var h3 = Math.max(0, Math.round((h1 * ishk.nh) / (ishk.nh - ishk.yd)));

        // apply new widths
        ishk.d[0].width = w0 + 'px';
        ishk.d[1].width = w1 + 'px';
        ishk.d[2].width = w0 + 'px';
        ishk.d[3].width = w1 + 'px';
        ishk.d[0].height = h0 + 'px';
        ishk.d[1].height = h0 + 'px';
        ishk.d[2].height = h1 + 'px';
        ishk.d[3].height = h1 + 'px';
        ishk.i[0].width = w2 + 'px';
        ishk.i[1].width = w3 + 'px';
        ishk.i[2].width = w2 + 'px';
        ishk.i[3].width = w3 + 'px';
        ishk.i[0].height = h2 + 'px';
        ishk.i[1].height = h2 + 'px';
        ishk.i[2].height = h3 + 'px';
        ishk.i[3].height = h3 + 'px';

        // looping current function
        setTimeout(ishk.shake, 20); // 1/50*1000 = 20ms (for 50 fps) <img src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
    }
};

window.onload = function() {
    ishk.init(); // first initialization

    // binding mouse move event
    document.onmousemove = function(e) {
        if (window.event) e = window.event; // for IE
        ishk.mousemove(e);
    }

    // binding onresize event
    window.onresize = ishk.resize;
}
</pre><p>It is rather simple. When the page loads &#8211; I initialize our main object, and link all the necessary events. Then, after initialization, I loop our main &#8216;shake&#8217; function, which changing sizes of all our 4 images (sectors).</p><h3>Step 4. Images</h3><p>For our demo I used only one image:</p><p><img
alt="img_01" src="http://www.script-tutorials.com/demos/71/image.jpg" width="585" height="439" /></p><hr
/><h5 style="text-align: center;"><strong><a
title="Cross-browser image shaking effect - demo 71" href="http://www.script-tutorials.com/demos/71/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cross-browser image shaking effect - demo 71" href="http://www.script-tutorials.com/demos/71/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today I told you how to create easy shaking effect to images. Commonly &#8211; you can try to play with any another objects too. Hope our javascript lessons still interesting for you. Good luck!</p><div
class="shr-publisher-613"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/flare-lens/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/89/thumb.png" alt="How to Create Cross Browser Compatible Flare Lens Effect using Javascript" /> <br
/> How to Create Cross Browser Compatible Flare Lens Effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/cross-browser-effect-of-waves-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/81/thumb.png" alt="Creating Cross-browser Compatible Wave Effects Using Javascript" /> <br
/> Creating Cross-browser Compatible Wave Effects Using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/particles-in-water/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/51.png" alt="Creating Animated Particles in Water Effect using JavaScript" /> <br
/> Creating Animated Particles in Water Effect using JavaScript</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Brilliant Examples of CSS3 Animations</title><link>http://www.script-tutorials.com/brilliant-examples-of-css3-animations/</link> <comments>http://www.script-tutorials.com/brilliant-examples-of-css3-animations/#comments</comments> <pubDate>Tue, 26 Apr 2011 17:47:30 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[resources]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[css3]]></category> <category><![CDATA[demonstration]]></category> <category><![CDATA[examples]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=563</guid> <description><![CDATA[CSS3 Animation demonstration Have you ever wondered about the use of CSS3 for creating videos? But in common it is possible too (using the animation features in CSS3). CSS3 is not fully mastered, many things may seem surprising for the average user. The only unpleasant moment, CSS3 is still not supported by most Web browsers [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/76/thumb.png" alt="How to use Multiple backgrounds and Animation with CSS3" /> How to use Multiple backgrounds and Animation with CSS3</a></li><li> <a
href="http://www.script-tutorials.com/fresh-10-html5-canvas-webgl-examples/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/117/thumb.jpg" alt="10 Fresh &#038; Impressive HTML5 Canvas (and WebGL) Examples" /> 10 Fresh &#038; Impressive HTML5 Canvas (and WebGL) Examples</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="CSS3 Animation demonstration" alt="CSS3 Animation demonstration" src="http://www.script-tutorials.com/demos/63/thumb.png"></div><p><strong>CSS3 Animation demonstration</strong><br
/> <br
/>Have you ever wondered about the use of CSS3 for creating videos? But in common it is possible too (using the animation features in CSS3). CSS3 is not fully mastered, many things may seem surprising for the average user. The only unpleasant moment, CSS3 is still not supported by most Web browsers at the moment. But do not worry, it&#8217;s a matter of time, and hopefully very soon, most browsers will support it. Well, Naomi Atkinson,  Andy Clarke, Dan Rubin and Mircea Piturca prepared website to the international community, demonstrating the power of animation in CSS.<br
/> <span
id="more-563"></span></p><hr
/><p>On <a
rel="nofollow" target="_blank" href="http://animatable.com/">this site</a> you already can view the video shows the possibilities of this project.</p><p><img
src="http://www.script-tutorials.com/demos/63/img1.png" title="coming possibilities of css3 animation" alt="coming possibilities of css3 animation" /></p><p>At the moment the project is still under development, but from the video, we see that the interface is quite complex and resembles the interface of video editor. But it seems that the animation will be very interesting and simple (as they promising from video) process.</p><p>At current moment <a
rel="nofollow" target="_blank" href="http://animatable.com/demos/madmanimation/">Madmanimation demo</a> working only <strong>at Webkit browsers (Chrome, Safari) </strong>on any platform or device — including Android, BlackBerry, iOS and WebOS. Other browsers possible not will display it.</p><p><a
rel="nofollow" target="_blank" href="http://animatable.com/demos/madmanimation/"><img
src="http://www.script-tutorials.com/demos/63/img2.png" title="" alt="Madmanimation demo in Chrome" /></a></p><p>If you are not a happy owner of the ones listed above you will see only the following</p><p><img
src="http://www.script-tutorials.com/demos/63/img3.png" title="" alt="Madmanimation demo in Firefox" /></p><p>Madmanimation demo using <a
rel="nofollow" target="_blank" href="http://www.w3.org/TR/css3-mediaqueries/">Media Queries</a>, so, it shoult ajust screen appearance due resizing sizes of browser <img
src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><hr
/><h3>Conclusion</h3><p>Well, let&#8217;s hope that everything will fine in this team, and soon all browsers will support CSS3 in full. Good luck !</p><div
class="shr-publisher-563"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/76/thumb.png" alt="How to use Multiple backgrounds and Animation with CSS3" /> <br
/> How to use Multiple backgrounds and Animation with CSS3</a></li><li> <a
href="http://www.script-tutorials.com/fresh-10-html5-canvas-webgl-examples/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/117/thumb.jpg" alt="10 Fresh &#038; Impressive HTML5 Canvas (and WebGL) Examples" /> <br
/> 10 Fresh &#038; Impressive HTML5 Canvas (and WebGL) Examples</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/brilliant-examples-of-css3-animations/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>How to Control Text Properties using jQuery and UI Slider</title><link>http://www.script-tutorials.com/text-animation-jquery-ui-slider/</link> <comments>http://www.script-tutorials.com/text-animation-jquery-ui-slider/#comments</comments> <pubDate>Fri, 04 Mar 2011 17:28:35 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[slider]]></category> <category><![CDATA[text control]]></category> <category><![CDATA[ui]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=378</guid> <description><![CDATA[How to Control Text Properties using jQuery and UI Slider Today I will tell how you can use jQuery to animate and control your text. We will changing font size, font family and other properties. Where we can use this? As example to allow your users to customize view of text boxes in your website. [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-rotate-slider-with-easing-effects/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/134/thumb.png" alt="Creating a Rotating Slider with Easing Effects in jQuery" /> Creating a Rotating Slider with Easing Effects in jQuery</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/72/thumb.png" alt="How to Create Animated Photo Gallery using jQuery (Slider Kit)" /> How to Create Animated Photo Gallery using jQuery (Slider Kit)</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-your-own-jquery-slider-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/78/thumb.png" alt="How to Create your own jQuery Slider Plugin" /> How to Create your own jQuery Slider Plugin</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p><strong>How to Control Text Properties using jQuery and UI Slider</strong></p><p>Today I will tell how you can use jQuery to animate and control your text. We will changing font size, font family and other properties. Where we can use this? As example to allow your users to customize view of text boxes in your website. So, playing with styles &#8211; users will be able to select preferred styles, and you will need just save these styles for him, or, you can use this as some zoon for your website, which will allow to change font size in realtime. Also we will using <strong>jQuery slider</strong> to manipulate with properties to make it more interactive.<br
/> <span
id="more-378"></span></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Text animation with jQuery slider - demo 32" href="http://www.script-tutorials.com/demos/32/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Text animation with jQuery slider - demo 32" href="http://www.script-tutorials.com/demos/32/source.zip" target="_blank">download in package</a></strong></h5><hr
/>Ok, download the source files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>This is our HTML file with 4 different sliders to change styles:</p><h4>index.html</h4><pre class="brush:html">&lt;link rel="stylesheet" href="css/jquery.ui.theme.css" type="text/css" /&gt;
&lt;link rel="stylesheet" href="css/jquery.ui.slider.css" type="text/css" /&gt;
&lt;link rel="stylesheet" href="css/main.css" type="text/css" /&gt;

&lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="js/jquery.ui.core.js"&gt;&lt;/script&gt;
&lt;script src="js/jquery.ui.widget.js"&gt;&lt;/script&gt;
&lt;script src="js/jquery.ui.mouse.js"&gt;&lt;/script&gt;
&lt;script src="js/jquery.ui.slider.js"&gt;&lt;/script&gt;
&lt;script src="js/main.js"&gt;&lt;/script&gt;

&lt;div class="examples"&gt;
    &lt;h2&gt;Text animation with jQuery and UI slider&lt;/h2&gt;
    &lt;div class="column"&gt;
        &lt;p&gt;
            &lt;label for="font_size"&gt;Font size:&lt;/label&gt;
            &lt;input type="text" id="font_size" style="border:0; color:#f6931f; font-weight:bold;" /&gt;
        &lt;/p&gt;
        &lt;div id="slider1"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="column"&gt;
        &lt;p&gt;
            &lt;label for="font_family"&gt;Font family:&lt;/label&gt;
            &lt;input type="text" id="font_family" style="border:0; color:#f6931f; font-weight:bold;" /&gt;
        &lt;/p&gt;
        &lt;div id="slider2"&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="column"&gt;
        &lt;p&gt;
            &lt;label for="font_weight"&gt;Font weight:&lt;/label&gt;
            &lt;input type="text" id="font_weight" style="border:0; color:#f6931f; font-weight:bold;" /&gt;
        &lt;/p&gt;
        &lt;div id="slider3"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="column"&gt;
        &lt;p&gt;
            &lt;label for="text_align"&gt;Text align:&lt;/label&gt;
            &lt;input type="text" id="text_align" style="border:0; color:#f6931f; font-weight:bold;" /&gt;
        &lt;/p&gt;
        &lt;div id="slider4"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div style="clear:both"&gt;&lt;/div&gt;
    &lt;div class="box"&gt;A man bribes a rabbit with wicked dentures to run away with him in a sailboat via an ambulance. Bribing Koalas to remain illegally in one place. Trees anchor me in place. / Your mom drives the ambulance, but the city is farther than it appears.&lt;/div&gt;
    &lt;div style="clear:both"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre><h3>Step 2. CSS</h3><p>Here are all used CSS files:</p><h4>css/main.css</h4><pre class="brush:css">body{background:#eee;font-family:Verdana, Helvetica, Arial, sans-serif;margin:0;padding:0}
.examples{background:#FFF;width:800px;font-size:80%;border:1px #000 solid;margin:3.5em auto 2em;padding:1em 2em 2em}
.column{float:left;width:45%;padding:20px}
.box{-moz-border-radius:5px;background-color:#DDD;border:1px solid #000;clear:both;width:50%;margin:10px auto;padding:10px}
</pre><h4>css/jquery.ui.slider.css, css/jquery.ui.theme.css</h4><p>Both these files belong to jQuery library, and no need to publish its code directly in our post, both files already available in package</p><h3>Step 3. JS</h3><h4>js/main.js</h4><pre class="brush:js">$(function() {
    $('#slider1').slider({
        value:12,
        min: 10,
        max: 20,
        step: 1,
        slide: function( event, ui ) {
            $('#font_size').val(ui.value + ' px');
            $('.box').css('font-size', ui.value);
        }
    });
    $('#font_size').val($('#slider1').slider('value') + ' px');

    var aFonts = new Array('', 'Verdana', 'arial', 'Tahoma', 'Times New Roman', 'Georgia');
    $('#slider2').slider({
        value:1,
        min: 1,
        max: 5,
        step: 1,
        slide: function(event, ui) {
            var sFontFamily = aFonts[ui.value];
            $('#font_family').val(sFontFamily);
            $('.box').css('font-family', sFontFamily);
        }
    });
    $('#font_family').val(aFonts[$('#slider2').slider('value')]);

    var aWeights = new Array('', 'normal', 'bold', 'bolder', 'lighter', 'inherit');
    $('#slider3').slider({
        value:1,
        min: 1,
        max: 5,
        step: 1,
        slide: function(event, ui) {
            var sFontWeight = aWeights[ui.value];
            $('#font_weight').val(sFontWeight);
            $('.box').css('font-weight', sFontWeight);
        }
    });
    $('#font_weight').val(aWeights[$('#slider3').slider('value')]);

    var aAligns = new Array('', 'left', 'right', 'center', 'justify');
    $('#slider4').slider({
        value:1,
        min: 1,
        max: 4,
        step: 1,
        slide: function(event, ui) {
            var sTextAlign = aAligns[ui.value];
            $('#text_align').val(sTextAlign);
            $('.box').css('text-align', sTextAlign);
        }
    });
    $('#text_align').val(aAligns[$('#slider4').slider('value')]);
});
</pre><p>Here are you can see initializations of 4 UI sliders. For changing font size, font family, bold style and text align for text of our text box. Hope this is very easy to understand how to use it.</p><h4>js/jquery.min.js, js/jquery.ui.core.js, js/jquery.ui.mouse.js, js/jquery.ui.slider.js, js/jquery.ui.widget.js</h4><p>All this &#8211; just jQuery libraries, its necessary for our UI slider. All these libraries available in package.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Text animation with jQuery slider - demo 32" rel="nofollow" href="http://www.script-tutorials.com/demos/32/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Text animation with jQuery slider - demo 32" rel="nofollow" href="http://www.script-tutorials.com/demos/32/source.zip" target="_blank">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that today&#8217;s article will very useful for your projects. Good luck!</p><div
class="shr-publisher-378"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-rotate-slider-with-easing-effects/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/134/thumb.png" alt="Creating a Rotating Slider with Easing Effects in jQuery" /> <br
/> Creating a Rotating Slider with Easing Effects in jQuery</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/72/thumb.png" alt="How to Create Animated Photo Gallery using jQuery (Slider Kit)" /> <br
/> How to Create Animated Photo Gallery using jQuery (Slider Kit)</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-your-own-jquery-slider-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/78/thumb.png" alt="How to Create your own jQuery Slider Plugin" /> <br
/> How to Create your own jQuery Slider Plugin</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/text-animation-jquery-ui-slider/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Easily Animate Web Buttons/Objects using jQuery</title><link>http://www.script-tutorials.com/easily-animate-web-buttonsobjects-using-jquery/</link> <comments>http://www.script-tutorials.com/easily-animate-web-buttonsobjects-using-jquery/#comments</comments> <pubDate>Wed, 08 Sep 2010 16:12:20 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[animation web objects]]></category> <category><![CDATA[css]]></category> <category><![CDATA[easing]]></category> <category><![CDATA[effects]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=205</guid> <description><![CDATA[Easily Animate Web Buttons/Objects using jQuery Today I will tell you about animations in web using jQuery. As we know &#8211; jQuery offer us several default methods of effects: fade(In/Out/To), hide, show, slide(Down/Toggle/Up), toggle. This is ok, but what if we need more? So, animation will help us! It will help to slide between 2 [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-rotate-slider-with-easing-effects/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/134/thumb.png" alt="Creating a Rotating Slider with Easing Effects in jQuery" /> Creating a Rotating Slider with Easing Effects in jQuery</a></li><li> <a
href="http://www.script-tutorials.com/positioning-background-with-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/2/bg.jpg" alt="Positioning Backgrounds with Jquery" /> Positioning Backgrounds with Jquery</a></li><li> <a
href="http://www.script-tutorials.com/easily-interact-between-server-and-client-using-these-jquery-with-ajax-snippets/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="Easily Interact between Server and Client using these jQuery with Ajax Snippets" /> Easily Interact between Server and Client using these jQuery with Ajax Snippets</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p><strong>Easily Animate Web Buttons/Objects using jQuery</strong><br
/> <br
/>Today I will tell you about animations in web using jQuery. As we know &#8211; jQuery offer us several default methods of effects: fade(In/Out/To), hide, show, slide(Down/Toggle/Up), toggle. This is ok, but what if we need more? So, animation will help us! It will help to slide between 2 states using really good effects. By default, &#8216;easing&#8217; is optional param, so to use extra effects we will use additional jquery.easing.js library.<br
/> <span
id="more-205"></span><br
/></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Animation in jQuery using easing - demo 14" href="http://www.script-tutorials.com/demos/14/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Animation in jQuery using easing - demo 14" href="http://www.script-tutorials.com/demos/14/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>As usual, we start with the HTML.</p><p>This is our main page code.</p><h4>index.html</h4><pre class="brush:html">
&lt;script src=&quot;js/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/jquery.easing.1.3.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;templates/css/main.css&quot; type=&quot;text/css&quot; /&gt;

&lt;div class=&quot;animation_example&quot;&gt;
    &lt;h3&gt;&lt;a href=&quot;#&quot;&gt;Animation in jQuery&lt;/a&gt;&lt;/h3&gt;
    &lt;div&gt;
        &lt;div style=&quot;margin-bottom:10px;&quot;&gt;
            &lt;h4&gt;Sample object:&lt;/h4&gt;
            &lt;div class=&quot;example_keeper&quot;&gt;
                &lt;img id=&quot;example&quot; src=&quot;files/image.jpg&quot;/&gt;
            &lt;/div&gt;
            &lt;div class=&quot;actions&quot;&gt;
                &lt;input type=&quot;radio&quot; value=&quot;width&quot; checked name=&quot;action&quot; class=&quot;action&quot;&gt; Changing width
                &lt;input type=&quot;radio&quot; value=&quot;position&quot; name=&quot;action&quot; class=&quot;action&quot;&gt; Changing position
                &lt;input type=&quot;radio&quot; value=&quot;opacity&quot; name=&quot;action&quot; class=&quot;action&quot;&gt; Changing opacity
                &lt;select class=&quot;selector&quot;&gt;&lt;/select&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;
            &lt;b&gt;An example of animations.&lt;/b&gt; I made 3 different types of animations: changing size (width), position and opacity. Also I pull all possible effects of easing into Select element. Just choose necessary type and select effect to get demonstration. Try it!
        &lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre><h3>Step 2. CSS</h3><p>Here are used CSS styles.</p><h4>templates/css/main.css</h4><pre class="brush:css">
body{background:#eee;font-family:Verdana, Helvetica, Arial, sans-serif;margin:0;padding:0}
.animation_example{background:#FFF;width:865px;font-size:80%;border:1px #000 solid;margin:0.5em 10% 0.5em;padding:1em 2em 2em;-moz-border-radius: 3px;-webkit-border-radius: 3px}
.actions{margin:10px 0}
.example_keeper{overflow: hidden;width:100%;height:520px;border:1px solid #DDD;background-color:#eee}
</pre><h3>Step 3. JS</h3><p>Here are necessary JS files to our project.</p><h4>js/main.js</h4><pre class="brush:js">
$(document).ready(function() {
    var sel1 = $(&quot;.selector&quot;);
    for (x in jQuery.easing) { // collecting all possible methods of easing
        sel1.append($('&lt;option&gt;').attr('value', x).text(x));
    }

    sel1.change(function(){
        var method = $(this).val();
        var effect = $('input[name=action]:checked').val();

        switch (effect) {
            case 'width':
                $('#example').animate({width:512}, {duration: 1000, easing: method})
                    .animate({width:256}, {duration: 1000, easing: method});
                break;
            case 'position':
                $('#example').animate({marginLeft:256}, {duration: 1000, easing: method})
                    .animate({marginLeft:0}, {duration: 1000, easing: method});
                break;
            case 'opacity':
                $('#example').animate({opacity:0}, {duration: 1000, easing: method})
                    .animate({opacity:1}, {duration: 1000, easing: method});
                break;
        }
    });
});
</pre><h4>js/jquery.easing.1.3.js and js/jquery.min.js</h4><p>This is common files &#8211; jQuery library with addon. No need to give full code of that file here. It always available as a download package</p><h3>Step 4. Images</h3><p>Also we need source image for our project:</p><pre class="sources">
    <img src="http://www.script-tutorials.com/demos/14/files/image.jpg" alt="source image" />
</pre><hr
/><h5 style="text-align: center;"><strong><a
title="Animation in jQuery using easing - demo 14" href="http://www.script-tutorials.com/demos/14/index.php" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Animation in jQuery using easing - demo 14" href="http://www.script-tutorials.com/demos/14/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today I told you how using animations in jQuery. Sure that you will happy to use it in your projects. Good luck!</p><div
class="shr-publisher-205"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-rotate-slider-with-easing-effects/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/134/thumb.png" alt="Creating a Rotating Slider with Easing Effects in jQuery" /> <br
/> Creating a Rotating Slider with Easing Effects in jQuery</a></li><li> <a
href="http://www.script-tutorials.com/positioning-background-with-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/2/bg.jpg" alt="Positioning Backgrounds with Jquery" /> <br
/> Positioning Backgrounds with Jquery</a></li><li> <a
href="http://www.script-tutorials.com/easily-interact-between-server-and-client-using-these-jquery-with-ajax-snippets/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="Easily Interact between Server and Client using these jQuery with Ajax Snippets" /> <br
/> Easily Interact between Server and Client using these jQuery with Ajax Snippets</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/easily-animate-web-buttonsobjects-using-jquery/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic (User agent is rejected)
Database Caching using disk: basic

Served from: www.script-tutorials.com @ 2012-02-04 21:46:03 -->
