<?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>Web Design Blog &#124; Web Design Fan &#124; Resources for Web Designers and Graphic Designers &#187; Tutorials</title>
	<atom:link href="http://webdesignfan.com/tag/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://webdesignfan.com</link>
	<description>Web Design Fan is a blog focused on the beautiful and interesting world of web design and development. We post tutorials, review web tools and services, give away graphics, and deliver all of the information web designers need the most.</description>
	<lastBuildDate>Mon, 21 May 2012 11:00:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>50 Astounding Adobe Illustrator Tutorials</title>
		<link>http://webdesignfan.com/50-astounding-adobe-illustrator-tutorials/</link>
		<comments>http://webdesignfan.com/50-astounding-adobe-illustrator-tutorials/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 20:43:07 +0000</pubDate>
		<dc:creator>Michael Huff</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Illustrator]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[roundup]]></category>
		<category><![CDATA[vectors]]></category>

		<guid isPermaLink="false">http://webdesignfan.com/?p=9100</guid>
		<description><![CDATA[Adobe Illustrator can be a little tricky to get your head around, particularly after getting used to the workflow of such applications as Photoshop. In this post we present a collection of excellent Adobe Illustrator tutorials for beginners and advanced designers. Click through to see the list.]]></description>
			<content:encoded><![CDATA[<p>Adobe Illustrator can be a little tricky to get your head around, particularly after getting used to the workflow of such applications as Photoshop.</p>
<p>In this post we present a collection of excellent Adobe Illustrator tutorials for beginners and advanced designers.</p>
<p>Have fun and Good Luck!</p>
<p>1. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-make-a-magic-book-using-adobe-illustrator/">Create a Magic Book Using Adobe Illustrator</a></p>
<p>In this tutorial will find out how to create a magic book. The first half of this tutorial is dedicated to creating an open book, and in the remaining steps you’ll  learn how to create the background and add the magic effects.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/1.png" alt="1 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>2. <a href="http://www.vectordiary.com/illustrator/gradient-mesh-flower-tutorial/">Gradient Mesh Flower</a></p>
<p>In this tutorial you will see how to use Gradient Mesh for creation of this wonderful flower.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/2.png" alt="2 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>3. <a href="http://andreiverner.com/freebies/how-to-create-a-bloody-halloween-ornament-using-adobe-illustrator/">Create Bloody Halloween Ornament Using Adobe Illustrator</a></p>
<p>In this 20 steps tutorial you will find out how to create a bloody Halloween ornament yourselves. The ornament is a bit psychedelic however it worth doing it.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/3.png" alt="3 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>4. <a href="http://www.webdesignshock.com/vintage-vector/">Realistic Vintage Vector Tutorial</a></p>
<p>In this tutorial you will discover how to make a great realistic typewriter with the help of Adobe Illustrator, so fasten your seat belts and let’s go.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/4.png" alt="4 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>5. <a href="http://www.computerarts.co.uk/tutorials/creating-trees-illustrator">Create Trees in Illustrator</a></p>
<p>In this tutorial you will see how to create a tree from a photograph. During the steps of this tutorial you will see the following tools in use: the freehand drawing tools, the shape tools and the Layers palette.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/5.png" alt="5 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>6. <a href="http://designinstruct.com/drawing-illustration/create-a-semi-realistic-light-bulb-in-adobe-illustrator/">Create A Semi Realistic Bulb</a></p>
<p>In this tutorial, you will  see how to create a light bulb illustration. It&#8217;s a good tutorial for those struggling with drawing freehand.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/6.png" alt="6 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>7. <a href="http://andreiverner.com/freebies/how-to-create-psychedelic-halloween-pumpkin-face-using-adobe-illustrator/">Create psychedelic Halloween pumpkin face using Adobe Illustrator</a></p>
<p>During this 20 steps Illustrator tutorial you will create a cool spooky 5-eyed pumpkin.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/7.png" alt="7 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>8. <a href="http://vector.tutsplus.com/tutorials/illustration/create-a-jellyfish/">Create a Jelly Fish In Adobe Illustrator</a></p>
<p>In this tutorial,  you will learn how to create a stylized jellyfish using blends and brushes.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/8.png" alt="8 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>9. <a href="http://vector.tutsplus.com/tutorials/illustration/create-a-sparkly-female-portrait-in-illustrator/">Create a Sparkly Female Portrait</a></p>
<p>This step-by-step tutorial will show you how to create a sparkly female portrait by playing with transparency and overlapping vector shapes.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/9.png" alt="9 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>10. <a href="http://vector.tutsplus.com/tutorials/illustration/create-a-painterly-landscape-with-the-blob-brush-tool/">Create a Painterly Landscape With the Blob Brush Tool</a></p>
<p>In this tutorial you will create a painterly landscape with an intuitive and versatile Blob Brush Tool.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/10.png" alt="10 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>11. <a href="http://www.vectordiary.com/illustrator/wooden-smoking-pipe-tutorial/">Create a Smoking Wooden Pipe</a></p>
<p>In this tutorial you will find out how to draw a stylish smoking tobacco pipe. You will also see how to create wood texture illustrator effect on the pipe.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/11.png" alt="11 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>12. <a href="http://vector.tutsplus.com/tutorials/illustration/tracing-a-vector-face-from-a-reference-photo/">Tracing a Vector Face From a Reference Photo</a></p>
<p>In this tutorial you will see the the process of tracing the basic shapes and contours of a photograph, as opposed to using predominately vector lines with strokes. This will result in a desirable, realistic yet stylized image.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/12.png" alt="12 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>13. <a href="http://abduzeedo.com/create-lava-island-scenario-illustrator">Create a Lava Island Scenario in Illustrator</a></p>
<p>This tutorial is inspired by the Tiki and Mario culture. You will see how to draw these Mario characters.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/13.png" alt="13 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>14. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-curious-owl-in-illustrator-cs4/">Create an Elegant Patterned Vector Owl</a></p>
<p>In this tutorial you will draw an elegant patterned vector owl.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/14.png" alt="14 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>15. <a href="http://blog.spoongraphics.co.uk/tutorials/how-to-create-a-gruesome-zombie-illustration">Zombie Illustration</a></p>
<p>In this step by step tutorial you will create a hand-drawn zombie illustration.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/15.png" alt="15 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>16. <a href="http://blog.spoongraphics.co.uk/tutorials/how-to-create-an-awesome-vector-skate-deck-design">Create an awesome vector skate deck</a></p>
<p>In this Adobe Illustrator tutorial you will create your own vibrant and stunning vector artwork using geometric lines, shapes and a perfect color scheme. The result is an awesome deck design ready for wall hanging, or hooking up with trucks and wheels for a session on the street!</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/16.png" alt="16 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>17. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-illustrate-a-lebron-james-cartoon-character/">How to Illustrate a LeBron James Cartoon Character</a></p>
<p>This tutorial shows how to create an illustration of a LeBron James.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/17.png" alt="17 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>18. <a href="http://www.computerarts.co.uk/tutorials/perfect-vector-portraiture">Perfect Vector Portraiture</a></p>
<p>In this tutorial by Simeon Elson you will see how to create a vector portrait.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/18.png" alt="18 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>19. <a href="http://blog.spoongraphics.co.uk/tutorials/create-a-rolling-stones-inspired-tongue-illustration">Rolling Stone Inspired Tongue</a></p>
<p>In this tutorial you will create a graphic design icon &#8211; the bright red Rolling Stones tongue and lips logo.  It&#8217;s not a direct copy of the original but an inspired tongue graphic, starting with a quick pencil sketch and finishing with a vector based graphic in Adobe Illustrator.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/19.png" alt="19 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>20. <a href="http://vectips.com/tutorials/create-a-grisly-zombie-illustration-with-a-pen-tablet/">Create an Grisly Zombie Illustration</a></p>
<p>In this tutorial you will create a zombie illustration with a pen tablet from a photo. Have fun utilizing the Blob Brush and Eraser tool in recreating this tutorial or apply these techniques to other ghoulish illustrations!</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/20.png" alt="20 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>21. <a href="http://psd.fanextra.com/tutorials/designing/create-an-awesome-music-poster/">Create an awesome music Poster</a></p>
<p>In this tutorial you will draw an awesome music poster.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/21.png" alt="21 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>22. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-realistic-vector-bubbles/">Create Realistic Bubble Effect</a></p>
<p>In this tutorial we will find out how to create realistic colorful bubbles. This tut covers numerous techniques.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/22.png" alt="22 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>23. <a href="http://blog.spoongraphics.co.uk/tutorials/how-to-design-a-skate-deck-with-a-cool-skull-pattern">Design a Skate deck With a Cool Skull Pattern</a></p>
<p>In this tutorial you will use Symbol Sprayer tool can for creating awesome pattern graphics and then combine them into an intricate pattern design to customize a skateboard deck.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/23.png" alt="23 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>24. <a href="http://www.gomediazine.com/tutorials/comic_book_style/">Comic Book Style Graphic Design</a></p>
<p>In this tutorial you will learn how to create awesome illustrations and turn them into flyers or posters.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/24.png" alt="24 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>25. <a href="http://vector.tutsplus.com/tutorials/character-design/how-to-create-a-stinking-zombie-flesh-eater-in-illustrator/">Stinking style Zombie Flesh Eater</a></p>
<p>In this tutorial, you will see how to create a cartoon zombie in Adobe Illustrator. Starting by creating a fresh corpse, you will then ‘yuck’ it up using a number of techniques.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/25.png" alt="25 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>26. <a href="http://layersmagazine.com/design-with-flare-from-start-to-finish-in-illustrator-cs4.html">Design With Flair</a></p>
<p>In this tutorial you will see how to apply flair technique. You will start from scratch with a basic photo and create a fully realized design.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/26.png" alt="26 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>27. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-transparent-battery-icon/">How to Create Transparent Battery icon</a></p>
<p>In this tutorial,  you will create a detailed battery icon similar to the one used in the iPhone.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/27.png" alt="27 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>28. <a href="http://designblurb.com/illustrator-making-of-an-abstract-artwork/">Making an abstract art Work</a></p>
<p>This tutorial shows you the principles of using the Live Paint Bucket tool, and what can be achieved with this great innovation in color management, which saves time, and may be used in countless sorts of project from character design to abstract Illustration.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/28.png" alt="28 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>29. <a href="http://illustrationclass.com/2007/03/07/test-your-creativity/">Test Your Creativity</a></p>
<p>In this simple Adobe Illustrator tutorial you will create some sort of abstract mask.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/29.png" alt="29 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>30. <a href="http://www.digitalartsonline.co.uk/tutorials/?featureID=3259640">Add Motion To Illustration Using lines</a></p>
<p>In this tutorial by Eric Van Den Boom you will see how to use lines and patterns to add a sense of motion to your illustration or photograph.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/30.png" alt="30 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>31. <a href="http://spyrestudios.com/how-to-create-an-awesome-retro-vw-beetle-vector-in-illustrator/">Create an Awesome Retro Beetle Type</a></p>
<p>In this tutorial you will create a vector image of an original Volkswagen Beetle using one of Illustrators most-used tools; the Pen Tool, as well as adding some finishing touches using a graphics tablet (an affordable Wacom Bamboo tablet in my case) to give the vector a nice hand-drawn style.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/31.png" alt="31 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>32. <a href="http://vector.tutsplus.com/tutorials/illustration/create-a-valentines-day-illustration-for-your-sweetie/">Create a Valentines Day Illustration For Your Sweetie</a></p>
<p>In this tutorial you will discover how to create a cheerful character and lovely, colorful bubbles. Use this knowledge to create a darling Valentine’s Day card for your sweetie.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/32.png" alt="32 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>33. <a href="http://www.webdesignerdepot.com/2009/06/create-a-realistic-candy-bar-in-illustrator/">Create a Realistic Candy Bar In Illustration</a></p>
<p>In this tutorial, you will see step by step how to create a realistic candy bar using Illustrator.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/33.png" alt="33 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>34. <a href="http://kevindyke.wordpress.com/2011/09/23/create-movement-in-your-illustrations/">Create Movement In Illustration</a></p>
<p>In this tutorial you will learn how to create stylistic lines that can be used to simulate movement.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/34.png" alt="34 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>35. <a href="http://vector.tutsplus.com/tutorials/effects/creating-a-toaster-popping-illustration/">Creating a Toaster popping Illustration</a></p>
<p>In this tutorial, you will learn how to apply such rare effect as the Chrome effect, which is used to create a metallic look.  You will also use Texturizer tool to create a toast texture.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/35.png" alt="35 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>36. <a href="http://andreiverner.com/freebies/how-to-use-brushes-in-adobe-illustrator-to-create-an-angry-octopus/">Create an Angry Octopus</a></p>
<p>This tutorial shows how to create an angry vector octopus character using brushes in Adobe Illustrator. It’s a simple 12 steps tutorial. Have fun!</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/36.png" alt="36 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>37. <a href="http://designinstruct.com/drawing-illustration/an-illustrators-project-from-start-to-finish/">From Start To Finish</a></p>
<p>In this tutorial,  you will find out how to create an illustration art piece so that you can witness what goes behind a digital illustrator’s work, as well as gain some new insights for your own projects’ workflow. We’ll go through conceptualization and idea gathering, creating illustrations in Illustrator, and then finishing the piece in Photoshop.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/37.png" alt="37 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>38. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-luxurious-gold-watch-in-adobe-illustrator/">Create a luxurious Gold Watch</a></p>
<p>In this tutorial you will see how to create a very realistic and stunning gold watch using simple tools and techniques like the Pathfinder, Blend, Clipping Mask, etc.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/38.png" alt="38 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>39. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-make-a-colorful-environmental-slice/">Make a colorful, Environment Slice</a></p>
<p>In this tutorial you will create an earth slice that looks like a piece of cake.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/39.png" alt="39 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>40. <a href="http://blog.spoongraphics.co.uk/tutorials/how-to-create-a-cubist-style-logo-design-in-illustrator">Create a Cubist Style Logo Design</a></p>
<p>In this tutorial you will see how to create a cubist style logo design made up of lots of detailed vector facets.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/40.png" alt="40 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>41. <a href="http://vector.tutsplus.com/tutorials/illustration/draw-a-realistic-vector-guitar-in-inkscape/">Create a Realistic Guitar</a></p>
<p>In this tutorial you will draw a realistic guitar from scratch using the free vector program.  This tut requires a basic knowledge of vector tools, such as: the Pen tool, Edit Path Nodes tools, and you should be familiar with the Fill and Stroke toolbox.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/41.png" alt="41 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>42. <a href="http://www.webdesignshock.com/icon-tutorial-video/">Create a Video Projector</a></p>
<p>In this Adobe Illustrator tutorial you will learn how to make an old film projector, such as the early 20th century. Get ready because it’s time to start, open your Illustrator and let’s go.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/42.png" alt="42 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>43. <a href="http://andreiverner.com/freebies/how-to-create-a-trippy-psychedelic-poster/">Create a trippy Psychedelic Poster</a></p>
<p>In this tutorial you will see how to make a funny psychedelic poster in Adobe Illustrator.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/43.png" alt="43 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>44. <a href="http://www.denisdesigns.com/blog/2011/07/create-a-clean-retro-badge-in-adobe-illustrator/">Create a Clean Retro Badge</a></p>
<p>In this tutorial you will draw a clean retro-looking badge/burst in Adobe Illustrator. These are great for adding to a website, advertisement, etc to help the text stand out.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/44.png" alt="44 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>45. <a href="http://vectorboom.com/load/tutorials/illustration/how_to_illustrate_a_tomato_using_adobe_illustrator/5-1-0-72">How to Illustrate a Tomato Using Adobe Illustrator</a></p>
<p>In this tutorial you  will use Meshes, Gradients and Blends for drawing a tomato. The skills you will learn here can easily be transferred to creating various objects. So let’s get started!</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/45.png" alt="45 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>46. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-make-a-white-holiday-scene-in-illustrator/">How To Make White Holiday Scene</a></p>
<p>In this tutorial you will create an entire winter landscape and fill it using numerous techniques, like blended blizzards, sprayed snowflakes, and more. The techniques you will use to create this illustration are fairly basic.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/46.png" alt="46 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>47. <a href="http://creativenerds.co.uk/tutorials/how-to-create-a-beautiful-windmill-illustration-using-illustrator/">How to Create a Beautiful Windmill</a></p>
<p>Windmills have been around for centuries and although their construction evolved through time the idea remains the same. Let this tutorial be a tribute to those old fashioned windmills that are hardly met these days.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/47.png" alt="47 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>48. <a href="http://blog.spoongraphics.co.uk/tutorials/how-to-create-a-grumpy-troll-character-in-illustrator">Create a Grumpy Troll Character</a></p>
<p>In this step by step tutorial  you will create a grumpy Internet troll character.  You will start the process with a basic pencil sketch then build up a complete vector character design with linework, color fills and basic shading to create a funny cartoon mascot.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/48.png" alt="48 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>49. <a href="http://vector.tutsplus.com/tutorials/illustration/create-a-picture-gallery/">Create a Picture Gallery In Gallery</a></p>
<p>In this tutorial you will see how to use 3D rendering, Blends, Opacity masks for creating this three-dimensional stage with vanishing points.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/49.png" alt="49 "  title="50 Astounding Adobe Illustrator Tutorials" /></p>
<p>50. <a href="http://mosquitosplace.com/2008/10/disco-ball-tutorial/">Create a Disco Ball</a></p>
<p>In this tutorial you will find out the right way for drawing a realistic disco ball.</p>
<p><img src="http://webdesignfan.com/tutimg/50bestill/50.png" alt="50 "  title="50 Astounding Adobe Illustrator Tutorials" />
<div class="shr-publisher-9100"></div>
]]></content:encoded>
			<wfw:commentRss>http://webdesignfan.com/50-astounding-adobe-illustrator-tutorials/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building a Compact jQuery News Ticker</title>
		<link>http://webdesignfan.com/building-a-compact-jquery-news-ticker/</link>
		<comments>http://webdesignfan.com/building-a-compact-jquery-news-ticker/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 17:03:34 +0000</pubDate>
		<dc:creator>Nathan Rohler</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://webdesignfan.com/?p=8070</guid>
		<description><![CDATA[<p>Many websites today feature a small news ticker that provides text links to pages with recent news or other features. It's a great way to highlight important links without using much space. In this tutorial, I'll show you how to easily build one of these news tickers using jQuery. We'll start with a HTML list of links, then use jQuery to make them automatically cycle, fading in and out. When the user hovers over a link, the ticker will pause so they can click the link to learn more.</p>]]></description>
			<content:encoded><![CDATA[<p>Many websites today feature a small news ticker that provides text links to pages with recent news or other features. It&#8217;s a great way to highlight important links without using much space. In this tutorial, I&#8217;ll show you how to easily build one of these news tickers using jQuery. We&#8217;ll start with a HTML list of links, then use jQuery to make them automatically cycle, fading in and out. When the user hovers over a link, the ticker will pause so they can click the link to learn more.</p>
<p>Before getting started, be sure to view the demo to see how the ticker works. Here&#8217;s what the finished project will look like:</p>
<div class="tutorial_image"><img src="/tutimg/newsticker/images/finished.png" width="541" height="409" alt="Finished ticker" title="Building a Compact jQuery News Ticker" /></div>
<p><a href="/tutimg/newsticker/files/finished.html">HTML Demo</a></p>
<p><span id="more-8070"></span></p>
<hr />
<h2>Tutorial Details</h2>
<ul>
<li><b>Technologies</b>: HTML, CSS, JavaScript, jQuery</li>
<li><b>Difficulty:</b> Intermediate</li>
<li><b>Estimated Completion Time:</b> 20-30 minutes</li>
</ul>
<hr />
<h2> <span>Intro:</span> Preparations</h2>
<p>You should create an empty HTML file and save it somewhere convenient now; we&#8217;ll be working with it throughout this tutorial. We&#8217;ll be working exclusively with client-side code, so there&#8217;s no need for a server &#8211; you can preview directly on your computer. In the demo files we&#8217;ll use inline CSS and JavaScript, but you can externalize these if desired.</p>
<p><strong> Tip:</strong> For this type of tutorial, it can be helpful to use <a href="http://jsbin.com/" target="_blank">jsBin</a> or <a href="http://jsfiddle.net/" target="_blank">jsFiddle</a> to follow along. These free online tools let you experiment with HTML, JavaScript and CSS without having to create any files on your computer. Best of all, you can save, version and share your experiments.  It&#8217;s a great way to perfect a technique without cluttering up your computer with tons of files.</p>
<p>If you&#8217;re creating your own HTML file, here&#8217;s the code you should have to start:</p>
<pre name="code" class="html">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;head>
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

  &lt;title>jQuery News Ticker&lt;/title>
  &lt;style type="text/css">
  /* CSS will go here */

  &lt;/style>
&lt;/head>

&lt;body>

  &lt;!-- Markup will go here --&gt;

  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js">&lt;/script>
  &lt;script type="text/javascript">
  // JavaScript will go here

  &lt;/script>
&lt;/body>
&lt;/html>
</pre>
<p>Note the designated places for markup, CSS and JavaScript. Additionally, note that we have included jQuery 1.6 from Google&#8217;s CDN.</p>
<hr />
<h2> <span>Step 1:</span> The HTML Markup</h2>
<p>We&#8217;ll use a dedicated <code>&lt;div&gt;</code> to hold the ticker. The links will be contained within an unordered list (<code>&lt;ul&gt;</code>). By using an HTML list to define the links, we ensure that the ticker will gracefully degrade for users with JavaScript disabled, and that search engines will still be able to see and follow all of the links. Add the following HTML markup to your page:</p>
<pre name="code" class="html">
&lt;div id=&quot;ticker&quot; class=&quot;newsTicker&quot;&gt;
    &lt;a href=&quot;#&quot;&gt;Newsroom&lt;/a&gt;
    &lt;span class=&quot;divider&quot;&gt;|&lt;/span&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#story1&quot;&gt;Story headline 1&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#story2&quot;&gt;Another Story headline 2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#story3&quot;&gt;Some third story headline&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#story4&quot;&gt;A final, fourth headline&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>Update the list to contain an <code>&lt;li&gt;</code> for each of the links you want in the ticker. I&#8217;ve chosen to put a &#8216;Newsroom&#8217; link at the start, but that&#8217;s up to you.</p>
<hr />
<h2> <span>Step 2:</span> Styling</h2>
<p>Now it&#8217;s time to make the scroller look nice. In the <code>&lt;style&gt;</code> tag in the <code>&lt;head&gt;</code>, add the following CSS:</p>
<pre>
#ticker
{
    border: 1px solid #666;
    background: #DDD;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    color: #333;
    font: 13px/16px Arial,Verdana,sans-serif;
    padding: 3px 7px;
    width: 400px;
}
#ticker .divider {
    padding: 0 4px;
}
#ticker a, #ticker a:visited
{
    color: #333;
    text-decoration: none;
}
#ticker a:hover
{
    color: #930;
}
</pre>
<p> This adds some background and border to the overall ticker, and styles the links. These styles are just to get you started &#8211; if you want, you can add some creativity at this point! As we style, keep in mind that the &lt;ul&gt; won&#8217;t be present in the rendered HTML &#8211; it will be replaced with a single link that changes. That&#8217;s why there are only link styles and no list-related styling.</p>
<hr />
<h2> <span>Step 3:</span> Making It Work</h2>
<p>Now we&#8217;re ready to add the jQuery-enhanced JavaScript to make the ticker actually work. I&#8217;ll show you the overall chunk first, then break down what each portion is doing. </p>
<p>Add the following chunk of JavaScript to the <code>&lt;script&gt;</code> tag at the bottom of the page:</p>
<pre name="code" class="js">
$(function()
{
    $('#ticker').each(function()
    {
        var ticker = $(this);
        var fader = $('&lt;span class=&quot;fader&quot;&gt;&amp;nbsp;&lt;/span&gt;').css({display:'inline-block'});
        var links = ticker.find('ul&gt;li&gt;a');
        ticker.find('ul').replaceWith(fader);

        var counter = 0;
        var curLink;
        var fadeSpeed = 600;
        var showLink = function()
            {
                var newLinkIndex = (counter++) % links.length;
                var newLink = $(links[newLinkIndex]);
                var fadeInFunction = function()
                    {
                        curLink = newLink;
                        fader.append(curLink).fadeIn(fadeSpeed);
                    };
                if (curLink)
                {
                    fader.fadeOut(fadeSpeed, function(){
                        curLink.remove();
                        setTimeout(fadeInFunction, 0);
                    });
                }
                else
                {
                    fadeInFunction();
                }
            };

        var speed = 5500;
        var autoInterval;

        var startTimer = function()
        {
            autoInterval = setInterval(showLink, speed);
        };
        ticker.hover(function(){
            clearInterval(autoInterval);
        }, startTimer);

        fader.fadeOut(0, function(){
            fader.text('');
            showLink();
        });
        startTimer();

    });
});
</pre>
<p>If you preview  now, you should see a working ticker that cycles through all of your links.  If you hover over the ticker, it will pause; if you move your mouse away again, it will restart. Now, let&#8217;s break down what all of that code is doing.</p>
<h3>Breaking Down the JavaScript &#8211; Overview</h3>
<p>In plain English, here&#8217;s what the JavaScript is doing:</p>
<ul>
<li>Everything is wrapped in a document-ready trigger, so it will be called once the document is ready for manipulation</li>
<li>We locate the news ticker</li>
<li>We create an array that references the links, then replace the unordered list element in the document with a holder <code>span</code>.  That holder will be used for displaying the current link.</li>
<li>We define a function that transitions from one link to the next</li>
<li>We create a timer, and set it to automatically pause when the user hovers over the ticker</li>
<li>We show the first link and start running the timer</li>
</ul>
<h3>Breaking Down the JavaScript &#8211; Details</h3>
<p>Now, lets take an in-depth look at what each of these pieces of code is doing. </p>
<p>Note that we use the <code>#ticker</code> selector to locate the ticker. If you had multiple tickers in your page, you could change this to <code>div.newsTicker</code> instead, since we applied a class of <code>newsTicker</code> to our ticker.</p>
<p><strong>Chunk 1 &#8211; Finding the content, Preparing the document</strong></p>
<pre name="code" class="js">
var ticker = $(this);
var fader = $('&lt;span class=&quot;fader&quot;&gt;&amp;nbsp;&lt;/span&gt;').css({display:'inline-block'});
var links = ticker.find('ul&gt;li&gt;a');
ticker.find('ul').replaceWith(fader);
</pre>
<p>In this first chunk, we create a jQuery reference</p>
<p>  to the current ticker. Then, we create a new <code>&lt;span&gt;</code> that will be used to hold the current link.  The <code>fader</code> class is applied, to enable styling if desired. Note that we set the <code>display</code> property of the span to <code>inline-block</code>.  This is important to enable fading of the text in Internet Explorer.  Without some annoyingly-complex trickery (treating the text as a block-level element to be precise), IE fails to fade the text. Next, we create a jQuery list that references all of the link elements that were defined in the markup, so we can use them later on. Having created this list, we destroy the unordered list, replacing it with the <code>fader</code> span.
</p>
<p><strong>Chunk 2 &#8211; Creating the &quot;Show me a new link&quot; function</strong></p>
<pre name="code" class="js">
var counter = 0;
var curLink;
var fadeSpeed = 600;
var showLink = function()
    {
        var newLinkIndex = (counter++) % links.length;
        var newLink = $(links[newLinkIndex]);
        var fadeInFunction = function()
            {
                curLink = newLink;
                fader.append(curLink).fadeIn(fadeSpeed);
            };
        if (curLink)
        {
            fader.fadeOut(fadeSpeed, function(){
                curLink.remove();
                setTimeout(fadeInFunction, 0);
            });
        }
        else
        {
            fadeInFunction();
        }
    };
</pre>
<p>In this next major chunk, we define the method that will fade the link in and out.  A counter keeps track of which link we&#8217;re on.  The <code>fadeSpeed</code> variable specifies how fast the fade effect should be.  By default, we use 600 milliseconds (0.6 seconds). Next, we define the function that will swap out the links. In this function we increment the counter and select the next link in the earlier-created list, automatically cycling back to the first by using the <a href="http://en.wikipedia.org/wiki/Modulo_operator" target="_blank">modulus operator</a> (%).  Then we define a temporary function that updates the reference to the current link, adds it to the <code>fader</code> span, then fades it in. Note that we fade the fader, not the link itself;  this is part of the trickery to make the fading work properly in IE.  Finally, we check to see if a link already is being displayed.  If so, we first fade out the fader and remove that link upon effect completion.  Then, after a microscopic delay to avoid item reference problems, we call the method to display the new link.  On the other hand, if no link exists, we just display the new link directly.</p>
<p><strong>Chunk 3 &#8211; Configuring Automatic progression, Starting it up</strong></p>
<pre name="code" class="js">
var speed = 5500;
var autoInterval;

var startTimer = function()
{
    autoInterval = setInterval(showLink, speed);
};
ticker.hover(function(){
    clearInterval(autoInterval);
}, startTimer);

fader.fadeOut(0, function(){
    fader.text('');
    showLink();
});
startTimer();
</pre>
<p>In the final chunk, we start things running. The speed variable defines (again, in milliseconds) how long each link should be visible when the ticker is automatically progressing. By default, we use 5500 (5.5 seconds). We define a <code>startTimer</code> method that creates an interval to call the earlier-defined <code>showLink</code> method every few seconds. Next, we add the listener that will automatically pause and restart the ticker when the user hovers over and leaves it. Then, to start the initial display, we instantly fade out the fader, empty its existing contents (a space character that&#8217;s required to force it to fade), and use <code>showLink</code> to fade in the first link. Finally, we start the timer.</p>
<hr />
<h2> <span>Summary</span></h2>
<p>You&#8217;ve now created a simple, compact news ticker to display newsworthy links on your site. The ticker functions properly in all browsers (including IE!) and automatically pauses when hovered-over, to ensure a good user experience. To enhance the ticker, you could use a server-side script (like PHP) to dynamically output the links. There are many possibilities! Moreover, you&#8217;ve learned about how jQuery&#8217;s document manipulation and effect tools can be leveraged to create nifty, useful widgets for your page. Have fun with your new knowledge!</p>
<div class="shr-publisher-8070"></div>
]]></content:encoded>
			<wfw:commentRss>http://webdesignfan.com/building-a-compact-jquery-news-ticker/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>25 Awesome Illustrated Character Tutorials</title>
		<link>http://webdesignfan.com/25-awesome-illustrated-character-tutorials/</link>
		<comments>http://webdesignfan.com/25-awesome-illustrated-character-tutorials/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 15:25:38 +0000</pubDate>
		<dc:creator>Satkrit Chapagain</dc:creator>
				<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[vectors]]></category>

		<guid isPermaLink="false">http://webdesignfan.com/?p=7958</guid>
		<description><![CDATA[Vector characters can establish a memorable image of your site in the reader's mind. In this roundup, we have compiled a list of 25 character design tutorials which will show you how to create beautiful and mind-blowing character designs.They contain a mixture of Photoshop and Illustrator tutorials and will be helpful for beginners to advanced users. Many of the tutorials will take you step by step on the design process from sketching to the coloring processing, shapes processing and contains many cool tricks which might come in handy during your next project.]]></description>
			<content:encoded><![CDATA[<p>Having a unique character on you website can be great as they can attract your visitor&#8217;s attention. Vector characters can establish a memorable image of your site in the reader&#8217;s mind. In this roundup, we have compiled a list of 25 character design tutorials which will show you how to create beautiful and mind-blowing character designs.They contain a mixture of Photoshop and Illustrator tutorials and will be helpful for beginners to advanced users. Many of the tutorials will take you step by step on the design process from sketching to the coloring processing, shapes processing and contains many cool tricks which might come in handy during your next project.</p>
<p>1. <a href="http://vectips.com/tutorials/create-a-cute-panda-bear-face-icon/">Cute Panda Bear Face </a></p>
<p><img src="/tutimg/ill_tuts/images/1.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In the following tutorial, you&#8217;ll learn how to create a cute panda bear face icon all from ellipses. The great part about this tutorial, is that you can easily apply the techniques to other icons, illustrations, logos, or other projects.</p>
<p>2. <a href="http://colorburned.com/2009/07/create-a-character-mascot-with-adobe-illustrator-cs4.html"> Character Mascot </a></p>
<p><img src="/tutimg/ill_tuts/images/2.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this intermediate Illustrator tutorial we will show you how to create a vector character mascot from a sketch in Adobe Illustrator CS4. The techniques in this tutorial can easily be applied to other illustrations, icons, and design elements; as well as legacy versions of Illustrator.</p>
<p>3. <a href="http://www.smashingmagazine.com/2008/02/13/drunken-monkey-photoshop-tutorial/"> Drunken Monkey</a></p>
<p><img src="/tutimg/ill_tuts/images/3.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this tutorial, You&#8217;ll learn step-by-step how I’ve designed an attractive character in one of our recent projects, namely for the company “Drunken Monkey Collectibles”. Sergio will review the entire design process, from the first sketches and drafts to the final touches with Adobe Photoshop.</p>
<p>4.<a href="http://vector.tutsplus.com/illustration/create-a-super-happy-octopus-character/"> Super Happy Octopus </a></p>
<p><img src="/tutimg/ill_tuts/images/4.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In Illustrator, it’s really easy to create fun characters with some simple shapes and the Pathfinder Panel. In the following tutorial I will explain how to create a Happy Octopus Character. You can use these techniques and elements to create whatever character you want!</p>
<p>5.<a href="http://www.blog.spoongraphics.co.uk/tutorials/create-a-cool-vector-panda-character-in-illustrator"> Panda </a></p>
<p><img src="/tutimg/ill_tuts/images/5.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>With just a few simple shapes, a mix of gradient colours and a few shadows here and there you can build some great looking illustrations. Here’s a step by step walkthrough of the process used to create a cool Panda character, from the basic outlines through to the detailed final design.</p>
<p>6.<a href="http://www.republicofcode.com/tutorials/photoshop/homer/"> Homer Simspon</a></p>
<p><img src="/tutimg/ill_tuts/images/6.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>This tutorial will teach you how to draw the Simpson&#8217;s favorite character, Homer Simpson, from the ground up. Our drawing project will involve drawing the outline of the character, applying strokes to these outlines, and then using various selection tools to color Homer&#8217;s skin and clothing. We will then finish it off by adding shadows and highlights to make it look similar to the image below.</p>
<p>7.<a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-web-site-mascot/"> Web Site Mascot</a></p>
<p><img src="/tutimg/ill_tuts/images/7.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this tutorial, I’m going to give an overview of how developed a character from the initial brief through to the final site mascot and then to go on to create several poses for different parts of the site.</p>
<p>8.<a href="http://www.illustrationclass.com/2008/07/07/thug-bunny/"> Thug Bunny! </a></p>
<p><img src="/tutimg/ill_tuts/images/8.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>This tutorial will go through the method of using symmetry in your artwork. Learn how to do half the work but still get the full benefit from your artwork. We’ll also feature a plugin for AI that speeds up your build time and cover the topic of “Opacity Masks.”</p>
<p>9.<a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-cute-bunny-vector-character/"> Bunny </a></p>
<p><img src="/tutimg/ill_tuts/images/9.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this Illustrator tutorial, I will show you how to create a cute bunny character. This tutorial uses simple shapes and gradients that are easy to apply to other character illustrations</p>
<p>10.<a href="http://www.computerarts.co.uk/tutorials/2d__and__photoshop/adding_dimension_to_your_characters"> Monster </a></p>
<p><img src="/tutimg/ill_tuts/images/10.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this tutorial, we show you how to add the illusion of dimension to your vector illustrations by combining the effects of Adobe Illustrator’s versatile linear and radial gradients. Along the way we’ll also demonstrate how subtle (and believable) accents can be applied to your illustration to increase lasting visual appeal. By working within the basic tools of Illustrator, including Transparency and Pathfinder functions, and combining them with more complex tasks such as clipping masks, you can build a dynamic vector illustration that breaks the stereotype of ‘flatness’.</p>
<p>11.<a href="http://vector.tutsplus.com/tutorials/illustration/how-to-illustrate-a-lebron-james-cartoon-character/"> Lebron James</a></p>
<p><img src="/tutimg/ill_tuts/images/11.png" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>Sure Lebron James isn&#8217;t in Cleveland anymore but with super and unique styled steps in making this tutorial, it is a must check out tutorials for all character fans.</p>
<p>12.<a href="http://vector.tutsplus.com/tutorials/character-design/how-to-create-a-stinking-zombie-flesh-eater-in-illustrator/"> Zombie </a></p>
<p><img src="/tutimg/ill_tuts/images/12.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this tutorial, I will show you how to create a cartoon zombie in Illustrator. Starting by creating a fresh corpse, we will then ‘yuck’ it up using a number of techniques. Let’s ‘rip’ this one apart!</p>
<p>13.<a href="http://www.computerarts.co.uk/tutorials/2d__and__photoshop/creating_vector_characters_in_illustrator"> Cute Monster</a></p>
<p><img src="/tutimg/ill_tuts/images/13.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>We talk through the essential steps, from before you even pick up a pen and paper to working your design up as a vector image, and show you some of our processes for adding details to the character.</p>
<p>14.<a href="http://www.blog.spoongraphics.co.uk/tutorials/create-a-cute-furry-vector-monster-in-illustrator"> Furry Vector Monster </a></p>
<p><img src="/tutimg/ill_tuts/images/14.jpg" alt="Character llustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>Follow these steps in Adobe Illustrator to create your very own super cute fuzzy monster character. We’ll be working with the basic shapes to start, then use a variety of gradients to add depth. We can then finish it off with some detailed fur effects to really lift the design from the screen.</p>
<p>15.<a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-curious-owl-in-illustrator-cs4/"> Curious Owl </a></p>
<p><img src="/tutimg/ill_tuts/images/15.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>16.<a href="http://www.cutelittlefactory.com/tutorials/design-a-cute-hamster-avatar/"> Cute Hamster Factory</a></p>
<p><img src="/tutimg/ill_tuts/images/16.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>17.<a href="http://vector.tutsplus.com/tutorials/character-design/create-character-driven-book-cover-art-using-illustrator-and-photoshop-part-1/"> Character Driven Book Cover Art </a></p>
<p><img src="/tutimg/ill_tuts/images/17.jpg" alt="Character  Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>In this two part tutorial on creating the “Let’s Go To Monster School!” book cover, I’ll show you a complete process from initial sketch to the final artwork, using an Illustrator to Photoshop integrated workflow. In Part 1 we will employ Illustrator to trace our hand drawn sketch, lay down the shapes and define the basic colors.</p>
<p>18.<a href="http://www.cutelittlefactory.com/tutorials/create-a-tiger-striped-cat-with-illustrator/"> Tiger Striped Cat </a></p>
<p><img src="/tutimg/ill_tuts/images/18.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>19.<a href="http://vector.tutsplus.com/tutorials/designing/how-to-create-a-vector-illustration-and-prepare-it-for-micro-stock-sale/"> Lost Kid </a></p>
<p><img src="/tutimg/ill_tuts/images/19.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>20. <a href="http://vector.tutsplus.com/tutorials/text-effects/how-to-create-typeface-characters/"> Typeface </a></p>
<p><img src="/tutimg/ill_tuts/images/20.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /><br />
21. <a href="http://www.webdesignerdepot.com/2011/05/how-to-create-a-cute-little-monster-in-illustrator"> Cute Little Monster </a></p>
<p><img src="/tutimg/ill_tuts/images/21.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>This tutorial is going to show a gradient-heavy illustration of a little monster. It’s got a 3-D feel, but it’s done using only gradients. So, stick with us; we’re going to use and see some really nice easy tips for creating this little monster. The tutorial is intended for beginners.</p>
<p>22.<a href="http://psd.tutsplus.com/tutorials/drawing/minion-despicable-me-photoshop/ "> Minion Despicable Me</a></p>
<p><img src="/tutimg/ill_tuts/images/22.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>23.<a href="http://vector.tutsplus.com/tutorials/illustration/how-to-turn-a-sketch-into-a-fat-cat-vector-illustration/ ">Fat Cat </a></p>
<p><img src="/tutimg/ill_tuts/images/23.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>Tutorial aims to guide you from sketchbook to screen; a “Fat Cat” doodled with biro translated into a neat vector caricature. Intermediate knowledge of Adobe Illustrator is advised.</p>
<p>24. <a href="http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-fantasy-character-in-illustrator/ "> Fantasy Character </a></p>
<p><img src="/tutimg/ill_tuts/images/24.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>This tutorial covers the process of creating a fantasy pinup illustration with Illustrator CS3. This tutorial uses Live Paint, so you will need CS2 or above to follow.</p>
<p>25. <a href="http://designinformer.com/create-a-cute-little-tiger-in-illustrator/ "> Cute Little Tiger</a></p>
<p><img src="/tutimg/ill_tuts/images/25.jpg" alt="Character Illustration Tutorials" title="25 Awesome Illustrated Character Tutorials" /></p>
<p>We offer best quality <a href="http://www.thetestking.org/exam/MB7-838.html">MB7-838</a> exam. You can get our 100% guaranteed <a href="http://www.thepass4sure.info/MB7-226-test.html">MB7-226</a> and <a href="http://www.pass4sures.biz/MB6-295-testking.html">MB6-295</a> to help you in passing the real exam of <a href="http://www.mypass4sure.info/70-595-dumps.html">70-595</a>.
<div class="shr-publisher-7958"></div>
]]></content:encoded>
			<wfw:commentRss>http://webdesignfan.com/25-awesome-illustrated-character-tutorials/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to Make an Image Magnifier in jQuery</title>
		<link>http://webdesignfan.com/how-to-make-an-image-magnifier-in-jquery/</link>
		<comments>http://webdesignfan.com/how-to-make-an-image-magnifier-in-jquery/#comments</comments>
		<pubDate>Tue, 24 May 2011 13:35:53 +0000</pubDate>
		<dc:creator>Charles Stover</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Premium]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[image magnifier]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[magnify]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://webdesignfan.com/?p=6334</guid>
		<description><![CDATA[This is a tutorial for what is the most complicated jQuery program I have written to date. It is a beautiful script with a simple output that has many potential uses. Undoubtedly, it caused me more stress than it should have, as I debated the most efficient method of displaying a cropped image. Should I use background position or image clipping, scaling or thumbnailing? Which of the many options between methods and styles are cross-browser compatible? After days of debate and testing, I found the perfect combination for a code that supports all high-request browsers (including Internet Explorer 6).]]></description>
			<content:encoded><![CDATA[<h3>Join the Fan Club!</h3>
<p>You are currently viewing a premium &#8220;Member&#8217;s Only&#8221; post from the <a href="http://webdesignfan.com/join-the-club/">Web Design Fan Club</a>. To continue viewing this awesome content after June 16, you can become a member for the heavily discounted of <b>$36/year </b>or join us on a monthly basis for <b>$9/month</b> after June 16.</p>
<p>Did you read that right? Yes, yes you did. <b>$36 for the year (8 months free) </b>if you become a yearly subscriber before June 16. Seems kind of foolish to pass something like that up, eh?</p>
<p>Joining the <a href="http://webdesignfan.com/join-the-club/">Web Design Fan Club</a> grants you access to all the incredible resources and knowledge you need to become an expert web designer. From WordPress themes to premium icon sets and vectors, advanced tutorials to educational resources and files, the Web Design Fan Club delivers. Not only that, but you gain access to interviews with some of the best web designers and developers working today.</p>
<p><a href="http://webdesignfan.com/join-the-club/"><img title="moneyback" src="http://webdesignfan.com/wp-content/uploads/2011/04/moneyback.png" alt="moneyback " width="475" height="100" /></a></p>
<hr class="hrstyle" />
<h3><a name="tutorial"></a>How to Make an Image Magnifier in jQuery</h3>
<ol>
<li> <a href="#intro">Introduction and Demo</a></li>
<li><a href="#function">Setting Up the Function</a></li>
<li><a href="#css">The CSS</a></li>
<li><a href="#elements-inner">Inner Magnification Elements</a></li>
<li><a href="#elements-blur-tint">Blur and Tint Magnification Elements</a></li>
<li><a href="#elements-shared">Shared Element Manipulation</a></li>
<li><a href="#inner-algorithm">The Inner Magnification Algorithm</a></li>
<li><a href="#blur-tint-algorithms">The Blur and Tint Algorithms</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
<h3><a name="intro"></a>Introduction</h3>
<p>This is a tutorial for what is the most complicated jQuery program I have written to date. It is a beautiful script with a simple output that has many potential uses. Undoubtedly, it caused me more stress than it should have, as I debated the most efficient method of displaying a cropped image. Should I use background position or image clipping, scaling or thumbnailing? Which of the many options between methods and styles are cross-browser compatible? After days of debate and testing, I found the perfect combination for a code that supports all high-request browsers (including Internet Explorer 6).</p>
<p>This script takes an image and its thumbnail, then lets the user to magnify in on a specific area of that thumbnail. This allows you to condense an otherwise large image into a small space. Below, for example, is a 1024&#215;768 image of a dog condense down to 320&#215;240.</p>
<h3>Demo: <a href="http://webdesignfan.com/demos/imagezoom.html">Image Magnifier Demo</a></h3>
<p>I feel the need to note that this does not magically transform a low-resolution image into a high-resolution image. It requires both a high-resolution and low-resolution version beforehand. It also supports many different forms of customization, which I tried to emphasize with the examples &#8211; from custom colors to custom &#8220;animations&#8221; (inner, blurred, tinted, and blurred tinted). This tutorial will teach you to make these scripts yourself in the ever-beloved jQuery by walking you through the algorithms used.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="function"></a>Setting Up the Function</h3>
<p>Of course, the first thing we&#8217;ll need to do is set up the function so that we may call the image magnifier easily. In order to create the function, we must first determine its parameters; and in order to determine its parameters, we must first determine what is likely to change on a per-call basis.</p>
<p>The dynamic features of each box are: whether or not it blurs, whether or not it tints, whether or not it magnifies inside the thumbnail (<a href="#inner">inner</a>), the low-resolution image and its dimensions, the high-resolution image and its dimensions, the border width of the boxes, the border color of each box, and the border style of each box. Considering there are three boxes (the thumbnail, the popup that contains the high-resolution image, and the box that surrounds the mouse to show you which area is magnified), that is <em>a lot</em> of variables!</p>
<p>Thankfully, we can use objects to condense similar variables in a single variable. We are then left with the effect, the low-resolution image, the high resolution image, and the style information of the boxes. Four variables.</p>
<pre class="javascript">
var imageMagnifier = function(effect, popup, thumbnail, css)
{
};
</pre>
<p>An example of these variables being sent to the function:</p>
<pre class="javascript">
imageMagnifier(
{borderWidth: 4, blur: false, inner: false, tint: "#ff0000"},
image = {src: "image-magnifier.jpg", height: 768, width: 1024},
thumbnail = {src: "image-magnifier-thumbnail.jpg", height: 240, width: 320},
{
popup: {borderColor: "#906030", borderStyle: "outset"},
thumbnail: {borderColor: "#604020", borderStyle: "solid"}
}
);
</pre>
<p>Border Width is not included in the CSS for one simple reason: aesthetics and calculability. If the border width of the mouse box (the box that surrounds the mouse when magnifying) is not the same as the border width of the thumbnail, its border cannot overlap the thumbnail border appropriately. I can think of no scenario where the mouse box border would need to differ from the thumbnail&#8217;s, and many errors and nuisances occurring as a result of having to change it within every CSS object.</p>
<p>You should also make sure all the effect variables are set. This allows for shorter code. Instead of having to check to see if the variable is defined and true (<code>typeof(effect.blur) != "undefined" &amp;&amp; effect.blur</code>), you can merely check to see if it is true.</p>
<pre class="javascript">
var imageMagnifier = function(effect, popup, thumbnail, css)
{
var effects = ["blur", "inner", "tint"];
for (var x = 0; x &lt; 3; x++)
{
if (typeof(effect[effects[x]]) == "undefined")
effect[effects[x]] = false;
}
};
</pre>
<p>Lastly, an extremely important variable needs to be established: the ratio of width to height between the thumbnail and the full-scale image (referred to herein as &#8220;popup,&#8221; since it pops up). This is necessary to determine both the size of the mouse box and how far to scroll the popup as your mouse scrolls across the thumbnail.</p>
<pre class="javascript">
var imageMagnifier = function(effect, popup, thumbnail, css)
{
var effects = ["blur", "inner", "tint"],
ratio = {
height: popup.height / thumbnail.height,
width: popup.width / thumbnail.width
};
for (var x = 0; x &lt; 3; x++)
{
if (typeof(effect[effects[x]]) == "undefined")
effect[effects[x]] = false;
}
};
</pre>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="css"></a>The CSS</h3>
<p>Before getting deep into the algorithms, it won&#8217;t hurt to cover and establish the CSS involved with the image magnifier. The static CSS is very short and to-the-point so will not take long to<br />
cover.</p>
<p>First is the very outer element, <var>div.image-magnify</var>, and its three most important inner elements: <var>div.box</var> (the mouse box), <var>div.popup</var> (the full-scale image), and <var>div.thumbnail</var>.</p>
<p>We&#8217;ll want to float the thumbnail and popup to the left so that they stack horizontally next to each other.</p>
<pre class="css">
<span class="cssSelector">div.image-magnify, div.image-magnify div.popup, div.image-magnify div.thumbnail {</span> float : left; <span class="cssSelector">}</span>
</pre>
<p>The box, popup, blur effect, and tint effect should be hidden by default, since they do not appear until you mouse over the thumbnail.</p>
<pre class="css">
<span class="cssSelector">div.image-magnify div.blur div, div.image-magnify div.box, div.image-magnify div.popup, div.image-magnify div.tint {</span> display : none; <span class="cssSelector">}</span>
</pre>
<p>The box needs to have a relative position so that it can shift around as the mouse moves.</p>
<pre class="css">
<span class="cssSelector">div.image-magnify div.box {</span> position : relative; <span class="cssSelector">}</span>
</pre>
<p>For aesthetic purposes, we&#8217;ll give <var>div.thumbnail</var> the curser of &#8220;move.&#8221;</p>
<pre class="css">
<span class="cssSelector">div.image-magnify div.thumbnail {</span> cursor : move <span class="cssSelector">}</span>
</pre>
<p>Now to explain the blur &#8220;algorithm&#8221; and its CSS. It&#8217;s a very simple idea, really, made especially easy with jQuery&#8217;s built-in translucency handler. You merely take a translucent image (I use 80% visibility for this magnifier) that&#8217;s been shifted to the left 3px, and place it over the same translucent image shifted up 3px. Then place those two images over the same translucent image shifted to the right 3px. Then place those three images over the same translucent image shifted down 3px. Seeing partially through each image will result in a blur effect. Here it is one image added at a time:</p>
<p><noscript>You need JavaScript enabled to see this effect occur.</noscript></p>
<p><script type="text/javascript">// < ![CDATA[
// < ![CDATA[
// < ![CDATA[
// < ![CDATA[
// < ![CDATA[
// < ![CDATA[
//< ![CDATA[ $("#blur-examples div.blur div").css({backgroundImage: 'url("' + directory + 'image-magnifier-thumbnail.jpg")', height: "240px", width: "320px"}).fadeTo(0, 0.8);
// ]]&gt;</script></p>
<p>Now that you understand how it blurs, you&#8217;ll easily understand the CSS for it:</p>
<pre class="css">
div.image-magnify div.blur &gt; div { background-position : -3px 0 <span class="cssMedia">}</span>
div.image-magnify div.blur &gt; div &gt; div { background-position : 0 -3px <span class="cssMedia">}</span>
div.image-magnify div.blur &gt; div &gt; div &gt; div { background-position : 3px 0 <span class="cssMedia">}</span>
div.image-magnify div.blur &gt; div &gt; div &gt; div &gt; div { background-position : 0 3px <span class="cssMedia">}</span>
</pre>
<p>We also have some dynamic CSS [in that it changes on a per-magnifier basis] that is referenced very often in the JavaScript. I&#8217;ve compressed it into a quick-access variable since that makes it easier to use each time than typing out each string.</p>
<pre class="javascript">
var imageMagnifier = function(effect, popup, thumbnail, css)
{
var cssCommon = {
background: "background-image : url('" + thumbnail.src.replace(/\'/g, "\\\'") + "');",
backgroundLarge: "background-image : url('" + popup.src.replace(/\'/g, "\\\'") + "');",
dimensions: "height : " + thumbnail.height + "px; width : " + thumbnail.width + "px;"
},
effects = ["blur", "inner", "tint"],
ratio = {
height: popup.height / thumbnail.height,
width: popup.width / thumbnail.width
};
cssCommon.thumbnail = cssCommon.background + " " + cssCommon.dimensions;
for (var x = 0; x &lt; 3; x++)
{
if (typeof(effect[effects[x]]) == "undefined")
effect[effects[x]] = false;
}
};
</pre>
<p><var>cssCommon.background</var> is the background image of the thumbnail, as it will be needed for <var>div.thumbnail</var>, <var>div.box</var>, and every div involved in blur. It becomes, then, much easier to reference it each time as <var>cssCommon.background</var> than its string equivalent.</p>
<p><var>cssCommon.backgroundLarge</var> is the background image of the popup. This variable is only used twice (once for the inner algorithm and once for the other effect algorithms), so is not nearly as common as the thumbnail background.</p>
<p><var>cssCommon.dimensions</var> is merely the dimensions of the thumbnail. Just like the background image, this applies to <var>div.thumbnail</var> and the blur divs. It does not apply to <var>div.box</var>, since its width is determined by the dimension ratio between the low-resolution and high-resolution images; but it does apply to <var>div.tint</var> which will need to overlay the thumbnail.</p>
<p>Lastly in <var>cssCommon</var>, we have <var>cssCommon.thumbnail</var>, which is merely a combination of the background and dimensions.</p>
<p>In summation, these are shorthand CSS applications for:</p>
<ul>
<li><var>cssCommon.thumbnail</var>: div.blur div, div.thumbnail</li>
<li><var>cssCommon.background</var>: div.box</li>
<li><var>cssCommon.backgroundLarge</var>: div.popup</li>
<li><var>cssCommon.dimensions</var>: div.tint</li>
</ul>
<p>As the final bit of CSS, each item in <var>div.image-magnify</var> will also lack a repeating background. We only want it to appear the one time. This is especially true for <var>div.blur</var> that has a shifted background position. When it shifts upward 3px, we don&#8217;t want those top 3px to appear at the bottom of the <var>div</var>, and so on and so forth for each direction that each blur element shifts.</p>
<pre class="css">
<span class="cssSelector">div.image-magnify div {</span> background-repeat : no-repeat; <span class="cssSelector">}</span>
</pre>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="elements"></a>The Elements</h3>
<p>Before all else, of course, we need to create the elements in order to assign event handlers to them. The inner magnify algorithm, unfortunately, is not compatible with the blur and tint algorithsm. This is simply due to the fact that the thumbnail is hidden when inner-magnified, so it cannot blur or tint. Because of this, and the position of the elements involved (<var>div.popup</var> being shifted to the left, <var>div.box</var> being non-existent), the inner magnify algorithm is split into an entirely different section of code than the blur and tint algorithms.</p>
<pre class="javascript">
var imageMagnifier = function(effect, popup, thumbnail, css)
{
var cssCommon = {
background: "background-image : url('" + thumbnail.src.replace(/\'/g, "\\\'") + "');",
backgroundLarge: "background-image : url('" + popup.src.replace(/\'/g, "\\\'") + "');",
dimensions: "height : " + thumbnail.height + "px; width : " + thumbnail.width + "px;"
},
effects = ["blur", "inner", "tint"],
ratio = {
height: popup.height / thumbnail.height,
width: popup.width / thumbnail.width
};
cssCommon.thumbnail = cssCommon.background + " " + cssCommon.dimensions;
for (var x = 0; x &lt; 3; x++)
{
if (typeof(effect[effects[x]]) == "undefined")
effect[effects[x]] = false;
}
if (effect.inner)
{
/* inner algorithm will go here */
}
else
{
/* blur and tint algorithms will go here */
}
};
</pre>
<h4><a name="elements-inner"></a>Inner Magnification Elements</h4>
<p>The most efficient setup <em>for inner magnification</em> is:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;image-magnify inner&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;thumbnail&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;popup&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>While <var>div.inner-magnify.inner</var> is never used in this tutorial, it is placed there simply for convenience if you desire to add other CSS effects.</p>
<p>Unlike blur and tint, <var>div.popup</var> is going to appear over <var>div.thumbnail</var>. For this, it is appropriately placed within <var>div.thumbnail</var>. Now to port this basic HTML layout to JavaScript to insert it into the function:</p>
<pre class="javascript">
if (effect.inner)
{
document.write(
'&lt;div class="image-magnify inner"&gt;' +
'&lt;div class="thumbnail" style="' + cssCommon.thumbnail + '"&gt;' +
'&lt;div class="popup" style="' + cssCommon.backgroundLarge + " " + cssCommon.dimensions + '"&gt;' +
'&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;'
);
}
</pre>
<p>Here I went one step further than the basic HTML layout: I applied the dynamic CSS discussed earlier. <var>div.thumbnail</var> receives the background image and dimensions of the thumbnail, and <var>div.popup</var> receives the background image of the high-resolution image and the dimensions of the thumbnail.</p>
<p>Now to put the finishing touches on <var>div.popup</var>. Due to the potential border on <var>div.thumbnail</var>, <var>div.popup</var> will need to be shifted up to the left by the same number of pixels as the border width. Otherwise, it will appear <em>inside</em> of <var>div.thumbnail</var>&#8216;s border, whereas we need it to appear <em>on top</em> of <var>div.thumbnail</var>&#8216;s border.</p>
<pre class="javascript">
if (effect.inner)
{
document.write(
'&lt;div class="image-magnify inner"&gt;' +
'&lt;div class="thumbnail" style="' + cssCommon.thumbnail + '"&gt;' +
'&lt;div class="popup" style="' + cssCommon.backgroundLarge + " " + cssCommon.dimensions + '"&gt;' +
'&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;'
);

// If a border exists, shift div.popup over it.
if (effect.borderWidth &gt; 0)
$("div.image-magnify:last div.popup").css("margin", "-" + effect.borderWidth + "px 0 0 -" + effect.borderWidth + "px");
}
</pre>
<div><a href="#tutorial">Back to Top</a></div>
<h4><a name="elements-blur-tint"></a>Blur and Tint Magnification Elements</h4>
<p>Unlike inner magnification, blur and tint will need a completely separate layout. They need to be designed in a way for them to both work at the same time, since they are compatible with each other. The most efficient setup is:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;image-magnify blur tint&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;thumbnail&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;blur&quot;</span>&gt;</span>
<span class="htmlComment"><span class="htmlOtherTag">&lt;!-- blur background shifted left 3px --&gt;</span></span>
<span class="htmlOtherTag">&lt;div&gt;</span>
<span class="htmlComment"><span class="htmlOtherTag">&lt;!-- blur background shifted up 3px --&gt;</span></span>
<span class="htmlOtherTag">&lt;div&gt;</span>
<span class="htmlComment"><span class="htmlOtherTag">&lt;!-- blur background shifted right 3px --&gt;</span></span>
<span class="htmlOtherTag">&lt;div&gt;</span>
<span class="htmlComment"><span class="htmlOtherTag">&lt;!-- blur background shifted down 3px --&gt;</span></span>
<span class="htmlOtherTag">&lt;div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;tint&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;box&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;popup&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>Like <var>div.image-magnify.inner</var>, <var>div.image-magnify.blur</var> (not to be confused with <var>div.image-magnify div.blur</var>) and <var>div.image-magnify.tint</var> are not used in this tutorial. They are listed merely for the convenience of custom CSS.</p>
<p>In this, the tinted element is placed on top of the blurred element so as to tint the blur (wheras the four blur images placed above the tint color would make the tint color barely noticeable). The box is placed inside the thumbnail, of course; and the popup is placed next to the thumbnail. Of course, if there is no blur or tint, the blur and tint elements won&#8217;t need to exist. This is handled in the JavaScript.</p>
<pre class="javascript">
if (effect.inner) { /* ... */ }
else
{
document.write(

// If the image is blurred and/or tinted, apply the blur and/or tint class.
'&lt;div class="image-magnify' + (effect.blur ? " blur" : "") + (effect.tint ? " tint" : "") + '"&gt;' +

// Give the thumbnail its background image and dimensions.
'&lt;div class="thumbnail" style="' + cssCommon.thumbnail + '"&gt;' +

// If the thumbnail is to be blurred, add the to-be-blurred thumbnails.
(effect.blur ? '&lt;div class="blur"&gt;&lt;div style="' + cssCommon.thumbnail + '"&gt;&lt;div style="' + cssCommon.thumbnail + '"&gt;&lt;div style="' + cssCommon.thumbnail + '"&gt;&lt;div style="' + cssCommon.thumbnail + '"&gt;' : '') +

// If the thumbnail is to be tinted, add an element of the appropriate color and dimensions.
(effect.tint ? '&lt;div class="tint" style="background-color : ' + effect.tint + '; ' + cssCommon.dimensions + '"&gt;&lt;\/div&gt;' : '') +

// If the thumbnail is blurred, close the blur elements.
// The opening and closing elements are separated so that div.tint will be inside of them.
(effect.blur ? '&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;' : '') +

/*
If the thumbnail is neither blurred, tinted, or inner, add a placeholder of the thumbnail dimensions.
If no placeholder exists, div.box will be thumbnail.height pixels higher than if a blur or tint element exists.
The placeholder will allow for div.box to use the same position algorithm regardless of effect used,
instead of having to make an exception for no-effect magnification.
*/
(!effect.blur &amp;&amp; !effect.tint ? '&lt;div style="' + cssCommon.dimensions + '"&gt;&lt;\/div&gt;' : '') +

// Add the mouse box with the thumbnail background. It needs its own background so that it is not affected by the blur or tint.
'&lt;div class="box" style="' + cssCommon.background + ' height : ' + Math.round(thumbnail.height / ratio.height) + 'px; top : -' + thumbnail.height + 'px; width : ' + Math.round(thumbnail.width / ratio.width) + 'px;"&gt;&lt;\/div&gt;' +

// Close div.thumbnail.
'&lt;\/div&gt;' +

// Add the popup with the full-scale background image and same dimensions as the thumbnail.
// Use negative right and bottom margins so that adjascent content is not affected by its position.
'&lt;div class="popup" style="' + cssCommon.backgroundLarge + ' margin-right : -' + (thumbnail.width + effect.borderWidth) + 'px; margin-bottom : -' + (thumbnail.height + effect.borderWidth) + 'px; ' + cssCommon.dimensions + '"&gt;&lt;\/div&gt;' +

// Close div.image-magnify.
'&lt;\/div&gt;'
);
}
</pre>
<p>For those of you wondering about the height and width attributes of <var>div.box</var>, fear not. It was simply too long to explain the comments. As hard as it is to explain mathematics, I shall attempt to do so here.</p>
<p>The box&#8217;s height and width need to be preportionate to the high-resolution image. That is to say that if the thumbnail is three times smaller than the popup, then the box needs to be three times smaller than the thumbnail. If the thumbnail is the same size as the popup, then the box needs to be the same size as the thumbnail. In other words, the box needs to be representative of what percentage of the popup is going to be shown.</p>
<p>The ratio variable is a measurement of popup to thumbnail. So a popup of 500 width and a thumbnail of 250 width would have a <var>ratio.width</var> of 2. <var>thumbnail.x</var> / <var>ratio.x</var> (where x is height or width) means that 1 / <var>ratio.x</var> is the percentage of the popup that will be shown. If the ratio of popup to thumbnail is 2:1, then 1/2 of the popup is what will be shown when magnified. For this ratio, the box should be 1/2 of the thumbnail. If the ratio of popup to thumbnail is 5:1, then 1/5 of the popup is what wlil be shown when magnified. For this ratio, the box should be 1/5 of the thumbnail. Thus, the box needs to be 1/<var>ratio.x</var> * <var>thumbnail.x</var> (or <var>thumbnail.x</var> / <var>ratio.x</var>).</p>
<div><a href="#tutorial">Back to Top</a></div>
<h4><a name="elements-shared"></a>Shared Element Manipulation</h4>
<p>There are also small manipulations that apply to both the inner, blur, and tint effects. Instead of redundently placing these snippets in both the <var>if</var> and <var>else</var> statements, we&#8217;ll execute them outside of the statements. They will need to go after the conditional because <var>div.image-magnify</var> must first exist in order for it to be manipulated.</p>
<pre class="javascript">
var imageMagnifier = function(effect, popup, thumbnail, css)
{
/* ... */
if (effect.inner) { /* ... */ }
else { /* ... */ }

// Assign important data that we'll need later.
$("div.image-magnify:last").data({
borderWidth: effect.borderWidth,
popupHeight: popup.height,
popupWidth: popup.width,
thumbnailHeight: thumbnail.height,
thumbnailWidth: thumbnail.width
});

// Apply the sent CSS.
$("div.image-magnify:last div.box, div.image-magnify:last div.popup, div.image-magnify:last div.thumbnail").css("border-width", effect.borderWidth + "px");
if (typeof(css) == "object")
{
for (x in css)
$("div.image-magnify:last div." + x).css(css[x]);
}
};
</pre>
<p><var>data()</var> is a very useful jQuery method that allows you to assign various attributes to an element. One cannot assign the attribute (<var>attr()</var>) of <var>popupHeight</var> to <var>div.image-magnify</var> because that is not a valid HTML attribute. Thankfully, jQuery will store it in that element&#8217;s <var>data()</var> so that one may access it later via <code>$("#the-element").data("popupHeight")</code>. <var>effect.borderWidth</var>, <var>popup.height</var>, <var>popup.width</var>, <var>thumbnail.height</var>, and <var>thumbnail.width</var> are all variables you will need to access in the future. They will be needed for calculations in various event handlers, which won&#8217;t be able to read the data sent to the <var>imageMagnifier()</var> function, so we thus store them in an easy-to-access location: the <var>div.image-magnify</var>&#8216;s <var>data()</var>.</p>
<p>Lastly, we apply the CSS. This includes <var>effect.borderWidth</var> and the <var>css</var> variable. Each element gets the same border width, and any custom CSS sent via the fourth parameter (e.g. custom border colors, border styles) will be assigned here as well.</p>
<p>And you&#8217;re done! At least with setting up the HTML. All that&#8217;s left is the algorithms for displaying specific regions of the box and popup.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="inner-algorithm"></a>The Inner Magnification Algorithm</h3>
<p>For easier reading, I will leave out the already-established function and variable declarations and merely discuss the coding that needs to be appended within the <code>if (effect.inner) { }</code> brackets.</p>
<p>We&#8217;ll need the trigger to make <var>div.popup</var> appear and disappear as needed. This part is very basic.</p>
<pre class="javascript">
$("div.image-magnify:last div.thumbnail")
// When you put your mouse over the thumbnail,
.mouseenter(
function(e)
{
// fade the popup to fully visible within a third of a second.
$(this).children("div.popup").fadeTo(333, 1);
}
)
// When you remove your mouse from the thumbnail,
.mouseleave(
function()
{
// fade the popup to fully invisible within a third of a second.
$(this).children("div.popup").fadeTo(333, 0);
}
);
</pre>
<p>Lastly, the ever-so-important algorithm itself. This is the part that moves the background of the full-resolution popup to match the background of the low-resolution thumbnail.</p>
<pre class="javascript">
$("div.image-magnify:last div.thumbnail")
.mousemove(
function(e)
{

// Get the data stored to the div.image-magnify image.
var data = $(this).parent().data(),

// Get the position of the thumbnail to determine the position of the mouse.
offset = $(this).offset();

// Re-calculate the ratio of popup to thumbnail.
var ratio = {
height: data.popupHeight / data.thumbnailHeight,
width: data.popupWidth / data.thumbnailWidth
},

// Get the X and Y coordinations of the mouse in relation to the thumbnail.
x = e.pageX - offset.left - data.borderWidth,
y = e.pageY - offset.top - data.borderWidth;

// Don't scroll beyond the thumbnail.
// Used to prevent scrolling when the mouse is on the border.
if (x &lt; 0)
x = 0;
if (x &gt; data.thumbnailWidth)
x = data.thumbnailWidth;
if (y &lt; 0)
y = 0;
if (y &gt; data.thumbnailHeight)
y = data.thumbnailHeight;

// Shift the background image of the popup
$(this).children("div.popup").css("background-position", (x &gt; 0 ? "-" + (x * (ratio.width - 1)) + "px" : 0) + " " + (y &gt; 0 ? "-" + (y * (ratio.height - 1)) + "px" : 0));
}
);
</pre>
<p>For those unaware, I&#8217;ll explain the variables used to calculate <var>x</var> and <var>y</var>. <var>e.pageX</var> is the mouse&#8217;s horizontal position on the page: the number of pixels the mouse is from the far left of the browser window or frame. <var>offset.left</var> is the thumbnail&#8217;s horizontal position on the page: the number of pixels the thumbnail is from the far left of the browser window or frame. By subtracting <var>offset.left</var> and <var>data.borderWidth</var> (the border width of the thumbnail) from <var>e.pageX</var>, you&#8217;re left with the mouse&#8217;s position in relation to the thumbnail. For example, if your mouse is positioned at the top left of the thumbnail, <var>x</var> will be 0 and <var>y</var> will be 0; if the mouse is positioned at the bottom middle of a 320&#215;240 thumbnail, <var>x</var> will be 160 and <var>y</var> will be 240.</p>
<p><var>div.popup</var>&#8216;s background positioning is a bit more complicated. The CSS for background position &#8211; unlike padding, margin, etc. &#8211; is comprised of the left position of the background followed by the top position of the background. Since the thumbnail is smaller than the high-resolution popup, this is where ratio comes into play. For every one pixel the mouse scrolls over the thumbnail, we&#8217;ll want to move <var>ratio.x</var> pixels in the popup; e.g. if the popup is three times the size of the thumbnail, we&#8217;ll want it to move three pixels for every pixel the mouse moves over the thumbnail. Your algorithm would then be <code>x * ratio.width</code> and <code>y * ratio.height</code>.</p>
<p>Unfortunately, it&#8217;s not quite that easy. <code>x * ratio.width</code> will place the pixel in the center of the mouse on the far left of the popup, when we want it in the center of the popup. Using that code, when you place your mouse on the far right of the thumbnail, the background position for the popup will be negative the width of the entire full-resolution image. Take for example, a thumbnail of 320&#215;240 and a popup of 640&#215;480: when your mouse is placed at the 320 x-coordinate of the thumbnail, the background position will be -640px (the mouse position [320] times the ratio [2]). If a 640px image is shifted to the left by 640px, you won&#8217;t be able to see it anymore! This isn&#8217;t what we want.</p>
<p>So how do we move the position from the far left to the center? You must first note the negative before the value in the CSS. The number we are calculating is how many pixels to the <em>right</em> the image should move; by using a negative, we thus make the image shift to the <em>left</em>. Beware the double negative in the following algorithm. -(<var>a</var> &#8211; <var>b</var>) actually means -<var>a</var> + <var>b</var> (moved <var>a</var> pixels to the left, then <var>b</var> pixels to the right). The uncondensed algorithm for determining the number of pixels to move the image to the <em>left</em> is this: <code>x * ratio.width - x / data.thumbnailWidth * data.thumbnailWidth</code>. That is to say, the pixel&#8217;s position in the full-resolution image (<code>x * ratio.width</code>) minus the percentage of the image scrolled (<code>x / data.thumbnailWidth</code>; we&#8217;re at pixel <var>x</var> out of <var>data.thumbnailWidth</var> pixels) times the number of pixels total (<var>data.thumbnailWidth</var>). In English, the further we scroll to the right, the more we&#8217;ll want to substract from <code>x * ratio.width</code>, up to 100% of the thumbnail width. When <var>x</var> is equal to <var>data.thumbnailWidth</var> (i.e. the mouse is at the far right of the thumbnail), we&#8217;ll be left with <code>x * ratio.width - <ins>1</ins> * data.thumbnailWidth</code>.</p>
<p>This is a fairly hard algorithm to grasp. If you do not understand how it works, it may serve well to toy with the numbers involved and watch the resulting effect for yourself.</p>
<p>Lastly, if the x or y coordinates are 0, simply use a 0 instead of the negative pixel value, because &#8220;-0px&#8221; is invalid CSS; thus the inline conditional statements, <code>(x &gt; 0 ? "-Zpx" : 0)</code>.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="blur-tint-algorithms"></a>The Blur and Tint Algorithms</h3>
<p>I will leave out the parts of the code already established to do away with redundancy and pointless scrolling. The following snippets are to be appended to the <code>else { }</code> block of code.</p>
<p>Like the inner algorithm, we must unhide the elements involved when the thumbnail is moused over. Very simple, but slightly longer than the inner algorithm due to the fact that more elements are involved (the mouse box, the blur elements, and the tint elements).</p>
<pre class="javascript">
$("div.image-magnify:last div.thumbnail")
.mouseenter(
function()
{
$(this).children("div.box").fadeTo(333, 1);
$(this).find("div.tint").fadeTo(333, 0.5);
$(this).find("div.blur div:not(div.tint)").fadeTo(333, 0.8);
$(this).parent().children("div.popup").css("display", "block").fadeTo(333, 1);
}
)
.mouseleave(
function()
{
$(this).children("div.box").fadeTo(333, 0);
$(this).find("div.tint").fadeTo(333, 0);
$(this).find("div.blur div").fadeTo(333, 0);
$(this).parent().children("div.popup").css("display", "none").fadeTo(333, 0);
}
);
</pre>
<p>When the mouse enters the thumbnail, fade in the mouse box and popup completely, fade in the tint element partially (so that you can still see through it), and fade in the blur elements to 80% to cause the blur effect.</p>
<p>When the mouse leaves the thumbnail, fade out the mouse box, tint element, blur elements, and popup completely.</p>
<p>Easy! Now for the dreaded algorithm.</p>
<pre class="javascript">
$("div.image-magnify:last div.thumbnail")
.mousemove(
function(e)
{
// Much like inner magnification, we will start with these same variables
// and determine the mouse position within the thumbnail.
var data = $(this).parent().data(),
offset = $(this).offset();
var ratio = {
height: data.popupHeight / data.thumbnailHeight,
width: data.popupWidth / data.thumbnailWidth
},
x = e.pageX - offset.left - data.borderWidth,
y = e.pageY - offset.top - data.borderWidth;

/*
Unlike inner magnification, we will be working with a mouse box.
We must then calculate the X and Y coordinates of the box, not the mouse.
Since the box has a width of thumbnail.width / ratio.width,
the x coordinate will be half the box's width to the left of the mouse
(while the other half of the box is to the right of the mouse).
*/
x = x - $(this).width() / ratio.width / 2;
y = y - $(this).height() / ratio.height / 2;

// If the would-be box is so far left that it's no longer on the thumbnail,
// don't put it any further left.
if (x &lt; 0)
x = 0;

/*
If the would-be box is so far right that it's no longer on the thumbnail,
(if the position of the left of the box plus the width of the box is further than the thumbnail width)
don't put it any further right.
(set the position of the left of the box to be the width of the thumbnail minus the width of the box)
*/
if (x + $(this).width() / ratio.width &gt; $(this).width())
x = $(this).width() - $(this).width() / ratio.width;

if (y &lt; 0)
y = 0;
if (y &gt; $(this).height() - $(this).height() / ratio.height)
y = $(this).height() - $(this).height() / ratio.height;

// Dealing with fractions, we better round. There's no such thing as a fraction of a pixel.
x = Math.round(x);
y = Math.round(y);

/*
Set the background position of the mouse box to match the position of the thumbnail.
Remember, it has its own background, because the thumbnail may be blurred or tinted.
Set the left and top attributes of the mouse box so that it scrolls with the mouse.
$(this).height() is subtracted from y, because div.box comes after div.blur and div.tint.
(Remember the placeholder created in the HTML?)
*/
$(this).children("div.box").css({
backgroundPosition: (x &gt; 0 ? "-" + x + "px" : 0) + " " + (y &gt; 0 ? '-' + y + "px" : 0),
left: (x - data.borderWidth) + "px",
top: (y - $(this).height() - data.borderWidth) + "px"
});

/*
Unlike inner magnification, the x and y values are representative of the left position in the mouse box, not the mouse itself.
Therefore when the mouse is at the far right of the image, the value of x still represents the far right minus the width of the box.
We thus do not need to substract anything when multiplying the x and y values by the ratio.
The popup's background position will never scroll the image out of view, because the x and y values is not allowed to reach the full dimensions of the thumbnail.
*/
$(this).parent().children("div.popup").css("background-position", (x &gt; 0 ? "-" + (x * ratio.width) + "px" : 0) + " " + (y &gt; 0 ? '-' + (y * ratio.width) + "px" : 0));
}
);
</pre>
<p>And there you have it. I find blur&#8217;s and tint&#8217;s algorithms to be much easier than inner&#8217;s, solely due to the fact that dealing with a mouse box that prevents scrolling beyond the dimensions of the thumbnail makes it easy to calculate the background of the popup.</p>
<p>For those wondering, it is entirely possible to use the mouse box&#8217;s algorithm in the inner magnification [without displaying the mouse box, of course]. I chose not to do so for one entirely aesthetic reason. When the box has reached the dimensions of the thumbnail, scrolling of the popup ceases. This isn&#8217;t very noticable with the mouse box, because you expect it to stop when the box&#8217;s border hits the thumbnail&#8217;s border. However, when there is no border guiding you, like with the inner magnification, it appears less fluid and more choppy. To see the difference for yourself, place your mouse in the bottom right corner of any of the magnification examples at the beginning of this tutorial. If you move it slightly to the left or up, nothing changes; the mouse box is still positioned as far to the bottom and right as it can go. However, if you do the same thing in the inner magnification example, it will scroll regardless of where your mouse is. It does not stop scrolling until your mouse is physically at the far right or far bottom of the thumbnail.</p>
<p>I find that to look better with an inner magnification. If you prefer using an invisible mouse box, you may simply copy-paste the algorithm from the blur and tint handler to the other.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="conclusion"></a>Conclusion</h3>
<p>If any reader (especially math majors) believes that he or she can explain the algorithms better than I did, feel absolutely free to do so in the comments. I will gladly edit them into the post itself to help future readers, giving credit where credit is due. I attempted to explain the algorithms to the best of my ability and as adequately as I believed they needed to be, but as a visual learner and memorizer, I&#8217;m aware of the difficulties of transcribing visual information.</p>
<p>Alas, thank you for reading!</p>
<h4><a href="http://webdesignfan.com/downloads/image-zoom.zip">Download the files here</a></h4>
<div><a href="#tutorial">Back to Top</a></div>
<p>Unlock the key of your success by <a href="http://www.thetestking.org/exam/MB6-502.html">MB6-502</a> and <a href="http://www.mytestking.us/exam/MB7-843.html">MB7-843</a>. By using our latest <a href="http://www.pass4sures.biz/MB5-294-testking.html">MB5-294</a>   study material, you can easily pass <a href="http://www.mypass4sure.info/70-529-dumps.html">70-529</a> exam.
<div class="shr-publisher-6334"></div>
]]></content:encoded>
			<wfw:commentRss>http://webdesignfan.com/how-to-make-an-image-magnifier-in-jquery/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How to Make a Graphical News Slider in jQuery</title>
		<link>http://webdesignfan.com/how-to-make-a-graphical-news-slider-in-jquery/</link>
		<comments>http://webdesignfan.com/how-to-make-a-graphical-news-slider-in-jquery/#comments</comments>
		<pubDate>Mon, 16 May 2011 13:35:53 +0000</pubDate>
		<dc:creator>Charles Stover</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Premium]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[news slider]]></category>
		<category><![CDATA[slideshow]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://webdesignfan.com/?p=6656</guid>
		<description><![CDATA[The graphical news slider: something used so often in so many places for so many different purposes. I had made one ages ago as one of my first jQuery projects. I figured I could write a tutorial to share that code with WebDesignFan's readers, but was taken aback when I reviewed the code I had made so long ago. It was not bad formatting or compatibility or any such thing, as I would never allow such problems to be a part of my programs. However, it wasn't very extensible as I feel all public code should be. It was merely designed to support the features I needed at the time. Having spent the last few days revising the code, namely to allow custom image dimensions, I am happy to share with you the revised code.]]></description>
			<content:encoded><![CDATA[<p><script src="http://webdesignfan.com/wp-content/uploads/2011/01/news-slider.min_1.js" type="text/javascript"></script></p>
<h3>Join the Fan Club!</h3>
<p>You are currently viewing a premium &#8220;Member&#8217;s Only&#8221; post from the <a href="http://webdesignfan.com/join-the-club/">Web Design Fan Club</a>. To continue viewing this awesome content after June 16, you can become a member for the heavily discounted of <b>$36/year </b>or join us on a monthly basis for <b>$9/month</b> after June 16.</p>
<p>Did you read that right? Yes, yes you did. <b>$36 for the year (8 months free) </b>if you become a yearly subscriber before June 16. Seems kind of foolish to pass something like that up, eh?</p>
<p>Joining the <a href="http://webdesignfan.com/join-the-club/">Web Design Fan Club</a> grants you access to all the incredible resources and knowledge you need to become an expert web designer. From WordPress themes to premium icon sets and vectors, advanced tutorials to educational resources and files, the Web Design Fan Club delivers. Not only that, but you gain access to interviews with some of the best web designers and developers working today.</p>
<p><a href="http://webdesignfan.com/join-the-club/"><img title="moneyback" src="http://webdesignfan.com/wp-content/uploads/2011/04/moneyback.png" alt="moneyback " width="475" height="100" /></a></p>
<hr class="hrstyle" />
<h3><a name="tutorial"></a>How to Make a Graphical News Slider in jQuery</h3>
<ol>
<li><a href="#intro">Introduction</a></li>
<li><a href="#html">The HTML</a></li>
<li><a href="#css">The CSS</a></li>
<li><a href="#object-variables">The Object and Important Variables</a></li>
<li><a href="#object-call">The Object Call</a></li>
<li><a href="#creating-styling">Creating and Styling the Elements</a></li>
<li><a href="#event-listener">Changing Slides Event Listener</a></li>
<li><a href="#fade">The Fade Algorithm</a></li>
<li> <a href="#slide">The Slide Algorithm</a>
<ol>
<li><a href="#diagonal">The Diagonal Algorithm</a></li>
<li><a href="#horizontal-vertical">The Horizontal and Vertical Algorithm</a></li>
</ol>
</li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
<h3><a name="intro"></a>Introduction</h3>
<p>The graphical news slider: something used so often in so many places for so many different purposes. I had made one ages ago as one of my first jQuery projects. I figured I could write a tutorial to share that code with WebDesignFan&#8217;s readers, but was taken aback when I reviewed the code I had made so long ago. It was not bad formatting or compatibility or any such thing, as I would never allow such problems to be a part of my programs. However, it wasn&#8217;t very <em>extensible</em> as I feel all public code should be. It was merely designed to support the features I needed at the time. Having spent the last few days revising the code, namely to allow custom image dimensions, I am happy to share with you the revised code.</p>
<p>In a nutshell, this program will take images and associated text/HTML, put them in a navigation bar, and periodically scroll through the images. A picture is worth a thousand words, so of course I&#8217;ll offer an example. The navigation bar below is set to be hidden until you put your mouse over the news slider. The slides are set to change automatically every 7.5 seconds, or when you click on a slide from the navigation bar.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="example"></a>Example</h3>
<h4><a href="http://webdesignfan.com/demos/slider.html">Graphic Slider in Javascript Demo</a></h4>
<h3><a name="html"></a>The HTML</h3>
<p>Just like with the previous image magnifier tutorial, I&#8217;ll explain the DOM structure before getting into the algorithms involved, as the algorithms are entirely dependant on the DOM.</p>
<pre class="html">
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;news-slider&quot;</span> id=<span class="htmlAttributeValue">&quot;news-slider-#&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;padding&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;background2&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;background&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;navigation bar&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;navigation icons&quot;</span>&gt;</span>
<span class="htmlImageTag">&lt;img alt=<span class="htmlAttributeValue">&quot;...&quot;</span> class=<span class="htmlAttributeValue">&quot;image#&quot;</span> src=<span class="htmlAttributeValue">&quot;...&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span> /&gt;</span>
<span class="htmlImageTag">&lt;img alt=<span class="htmlAttributeValue">&quot;...&quot;</span> class=<span class="htmlAttributeValue">&quot;image#&quot;</span> src=<span class="htmlAttributeValue">&quot;...&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span> /&gt;</span>
<span class="htmlImageTag">&lt;img alt=<span class="htmlAttributeValue">&quot;...&quot;</span> class=<span class="htmlAttributeValue">&quot;image#&quot;</span> src=<span class="htmlAttributeValue">&quot;...&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span> /&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;text&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div&gt;</span>...<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>Of course we&#8217;ll wrap all of the elements in a <var>div.news-slider</var> element. Since we&#8217;ll be needing timeouts in JavaScript to change the background and text periodically, we&#8217;ll need a unique identifier (<var>div#news-slider-1</var>, <var>div#news-slider-2</var>, <var>div#news-slider-3</var>, etc.) to refer to which slider needs to change from within the timeout.</p>
<p><var>div.padding</var> is to prevent an error in older versions of Internet Explorer. If padding (e.g. 10px) is applied to an element that also contains a height or width (e.g. 600px), Internet Explorer would alter that element&#8217;s height or width to include the padding (e.g. 620px). In other words, the width would apply to what is <em>inside</em> of the padding instead of the element as a whole. By placing the padding in an element within the fixed-width, Internet Explorer is forced to render the padding <em>inside</em> the width instead of vice-versa, ensuring cross-browser appearance compatibility.</p>
<p><var>div.background2</var> is a dummy element used for transition effects. During transitions, two backgrounds are displayed: the new that is one coming into focus and the old one that is leaving. Thus, we&#8217;ll need two elements: <var>div.background</var> for the new background and <var>div.background2</var> for the old background. Since <var>div.background</var> will be the new background that is in-focus, I&#8217;ve placed it <em>after</em> <var>div.background2</var>. By placing it after (and then shifting it upward via the CSS <var>top</var> attribute), it will appear <em>on top of</em> <var>div.background2</var>, thus hiding the old background when the new one comes into focus.</p>
<p><var>div.navigation.bar</var> is merely a colored bar on top of which the navigation images appear. I gave it a separate element from the images themselves because it will be translucent, so the viewer is able to see the background image of <var>div.background</var> through it. I did not place the images inside <var>div.navigation.bar</var>, because I did not want the images to be translucent. Therefore, like with <var>div.background</var>, I placed the images in the proceeding element, then merely shifted them on top of <var>div.navigation.bar</var>. Since <var>div.navigation.bar</var> and <var>div.navigation.icons</var> share so many attributes (height, width, position), I gave them the common class <var>.navigation</var>. The separate class <var>.bar</var> is used for coloring the navigation bar, while <var>.icons</var> is unused and merely there for convenience of anyone who wants to stylize it.</p>
<p><var>img.image#</var> are semi-unique class names that will be used in jQuery to gather information about the image, e.g. it&#8217;s <var>src</var> via <code>$("news-slider-1 img.image1").attr("src")</code>. I say semi-unique, because it is not unique to the page (therefore using class instead of ID) merely unique to the slider (each slider only has one <var>.image1</var>, one <var>.image2</var>, one <var>.image3</var>, etc.).</p>
<p><var>div.text</var> is the text that will display. The <var>div</var> element inside of it is similar to <var>div.padding</var>. Oddly enough, it is not to appease Internet Explorer, but to appear jQuery. In order to position <var>div.text</var> toward the bottom or right of <var>div.news-slider</var>, we will need to know it&#8217;s <var>width()</var> and <var>height()</var> (jQuery functions). Unfortunately, jQuery does not include border or padding in its calculations of width and height, thus will not calculate the <em>visible</em> width and height of the element, thus not positioning <var>div.text</var> where we want to position it. To fix this, we merely use a <var>div</var> element inside of <var>div.text</var> for border, padding, etc. This will cause <var>div.text</var> to stretch and the <var>.width()</var> and <var>.height()</var> of <var>div.text</var> to change, incorporating the border, padding, etc. of its inner <var>div</var>.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="css"></a>The CSS</h3>
<p>Now that you know what the elements are, we must set their default styles to position them appropriately!</p>
<pre class="css">
<span class="cssSelector">div.news-slider {</span>
background-color : #f8d8d0;
<span class="cssProperty">border</span><span class="cssRest">:</span><span class="cssValue"> 1px outset #e0d0c0</span><span class="cssRest">;</span>
height : 320px;
margin : 0 auto;
text-align : left;
width : 620px;
<span class="cssSelector">}</span>

<span class="cssSelector">div.news-slider div.padding {</span>
padding : 10px;
<span class="cssSelector">}</span>
</pre>
<p>The attributes of the slider itself are pretty self-explanatory. <code>margin : 0 auto;</code> is to center it. If you are using multiple news sliders with multiple widths, use <code>#news-slider-1</code>, <code>#news-slider-2</code>, <code>#news-slider-3</code>, etc. to set the height and width values.</p>
<pre class="css">
<span class="cssSelector">div.news-slider div.background, div.news-slider div.background2 {</span>
background-repeat : no-repeat;
height : 300px;
margin-bottom : -300px;
width : 600px;
<span class="cssSelector">}</span>
</pre>
<p>The two backgrounds are very similar elements and thus have the same attributes. We don&#8217;t want the background to repeat so that we can see both at the same time (instead of just the one positioned on top of the other). The bottom must be set to the negative of the height. This will &#8220;pull&#8221; anything below it on top of it, essentially giving it a &#8220;height&#8221; of 0, even though it is still visible. Therefore, <var>div.background2</var>&#8216;s negative <var>margin-bottom</var> will cause <var>div.background</var> to render on top of it, while <var>div.background</var>&#8216;s negative <var>margin-bottom</var> will cause <var>div.navigation.bar</var> to render on top of it.</p>
<pre class="css">
<span class="cssSelector">div.news-slider div.navigation {</span>
height : 300px;
position : relative;
margin-bottom : -300px;
text-align : center;
width : 142px;
<span class="cssSelector">}</span>
</pre>
<p>Here we have the shared attributes of the navigation bar and its icon wrapper. The height is the same as the background height. The position is relative so that it can be placed on the left or right of the slider. The bottom margin &#8220;pulls&#8221; <var>div.navigation.icons</var> on top of <var>div.navigation.bar</var> and <var>div.text</var> on top of <var>div.navigation.icons</var>. The centered alignment centers the images in <var>div.navigation.icons</var>. The width can be whatever you like. Simple.</p>
<pre class="css">
<span class="cssSelector">div.news-slider div.navigation.bar {</span>
background-color : #e0d0c0;
<span class="cssSelector">}</span>
</pre>
<p>The background color of the navigation bar. You can also use a background image if you want, but keep in mind that it will translucently overlay <var>div.background</var>.</p>
<pre class="css">
<span class="cssSelector">div.news-slider div.navigation img {</span>
border : #000000 solid 2px;
cursor : pointer;
height : 59px;
margin-top : 10px;
width : 118px;
<span class="cssSelector">}</span>

<span class="cssSelector">div.news-slider div.navigation img:hover {</span>
border-color : #808080;
<span class="cssSelector">}</span>

<span class="cssSelector">div.news-slider div.navigation img.selected {</span>
border-color : #ffffff;
<span class="cssSelector">}</span>
</pre>
<p>These are the attributes of the images in the navigation bar. The height and width are based on how many images are going to appear in the bar. This takes a bit of calculation to determine:</p>
<p>The height of the navigation bar is 300. The number of images is 4. The padding between the images is 10. The border width of the images is 2.</p>
<ol>
<li>Multiple the padding (10) by the number of images (4): 40.</li>
<li>Add the padding (10) to that to include the padding at the bottom of the navigation bar: 50.If you have 4 images, you&#8217;ll want 10px above the first image (10), 10px above the second image (20), 10px above the third image (30), 10px above the fourth image (40), and 10px <em>below</em> the fourth image (50).That comes out to be 50 pixels of the 300 height that will be padding.</li>
<li>Multiply the border width (2) of the images by 2: 4.If you have a border width of 2, that&#8217;s 2px on the border top and 2px on the border bottom.That comes out to be 4px total added to the vertical height of the image.</li>
<li>Multiply that number (4) by the number of images (4): 16.</li>
<li>Subtract that number (16) and the total padding (50) from the height (300): 234.This is how much of your navigation bar is <em>not</em> border or padding.i.e. This is how much of your navigation bar can actually be used for images.</li>
<li>Divide that number (234) by the number of images (4): 58.5.</li>
<li>Round that number (58.5) if necessary: 59.This is the height of each individual image.The width of each image can be calculated using the height-to-width ratio of the original image and this new height.</li>
</ol>
<pre class="css">
<span class="cssSelector">div.news-slider div.text {</span>
display : none;
float : left;
position : relative;
<span class="cssSelector">}</span>

<span class="cssSelector">div.news-slider div.text div {</span>
background-color : #404040;
border : #000000 solid 1px;
color : #e0d0c0;
float : left;
font-family : <span class="cssString">"Verdana"</span>, <span class="cssString">"Tahoma"</span>, sans-serif;
font-size : 13px;
line-height : 17px;
padding : 2px 6px;
<span class="cssSelector">}</span>

<span class="cssSelector">div.news-slider div.text div a {</span>
color : #e0d0c0;
<span class="cssSelector">}</span>
</pre>
<p>Lastly, these are the attributes of the text that displays with each image. By default, it is hidden, as it will become displayed when the image appears. It and its inner div are floated left so that their widths will match their text instead of being 100% and so it may be positioned (note <code>position : relative;</code>) from the left of the news slider to its appropriate location (e.g. the right side of the slider if the developer chooses so).</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="object-variables"></a>The Object and Important Variables</h3>
<p>The news slider is placed in an object instead of a function. It requires at least two variables &#8211; one function to create the slider and one array to keep track of the timeouts used in changing slides. By using an object, we can store both of these in a single variable, while allowing the extensibility of storing other variables in the object for convenience.</p>
<pre class="javascript">
var newsSlider = {
create: function(){},
htmlSpecialChars: function(){},
specialChars: {},
timeouts: [],
total: 0
};
</pre>
<p><var>newsSlider.create</var> is simply the function used to create the slider and output the HTML. Unless you are writing custom mods, this will be the only part of the object you will ever call. An example of such a call and its parameters is explained in the following section.</p>
<p><var>newsSlider.htmlSpecialChars</var> is a function, similar to PHP&#8217;s <a title="PHP: htmlspecialchars - Manual" href="http://us3.php.net/manual/en/function.htmlspecialchars.php">htmlspecialchars</a>. It is used to store HTML in the image&#8217;s <var>alt</var> attribute by temporarily stripping out the HTML. <var>newsSlider.specialChars</var> is a variable used by <var>newsSlider.htmlSpecialChars</var>. For an in-depth explanation of this function and variable, give <a href="http://webdesignfan.com/htmlspecialchars-in-javascript/">htmlspecialchars in JavaScript</a> a read.</p>
<p><var>newsSlider.timeouts</var> is an array of timeouts created by <var>setTimeout</var>. These need to be stored so that they may be cleared via <var>clearTimeout</var> when necessary.</p>
<p><var>newsSlider.total</var> is merely an integer of the total news sliders on the page. It is used in the code to determine what ID should be used for the news sliders, but may also prove useful for any modification you may create: <var>$(&#8220;#news-slider-&#8221; + newsSlider.total)</var> will reference the last slider created.</p>
<p>With <var>timeouts</var> being an empty array, <var>total</var> being 0, and <var>htmlSpecialChars</var> and <var>specialChars</var> being given to you in the aforementioned tutorial, the only code left is <var>newsSlider.create</var>. Besides it, this object is done.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="object-call"></a>The Object Call</h3>
<p>Before we can create <var>newsSlider.create</var>, we need to know what we&#8217;re working with. What is a simple interface for the developer to manipulate? How many variables with which will we be working, and what will they be called? To figure out this information, I&#8217;ve added the object call prior to the final bit of code: <var>newsSlider.create</var>.</p>
<pre class="javascript">
newsSlider.create({
align: "left",
backgrounds: ["news-slider-4.jpg", "news-slider-3.jpg", "news-slider-2.jpg", "news-slider-1.jpg"],
direction: false,
effect: "random",
hide: true,
text: ["Nintendo 3DS coming out in March 2011", '&lt;a href="http://webdesignfan.com/how-to-design-a-stylish-business-card-in-photoshop/"&gt;How to Design a Stylish Business Card in PhotoShop&lt;\/a&gt;', '&lt;a href="http://webdesignfan.com/yslow-tutorial-part-1-of-3-minimizing-file-size/"&gt;YSlow Tutorial, Part 1 of 3: Minimizing File Size&lt;\/a&gt;', "Ted Williams offered full-time job by Cleveland Cavaliers"],
valign: "bottom"
});
</pre>
<p>As you can see, the parameters are all passed as an object, for simplicity reasons, as opposed to memorizing an arbitrary order of parameters.</p>
<p><var>align</var> is the location of the navigation bar. It may be either left or right. The text will align oppose the navigation bar&#8217;s alignment. If you set this parameter to left, the navigation bar will be on the left, and the text will be on the right. If you set this parameter to right, the navigation bar will be on the right, and the text will be on the left.</p>
<p><var>backgrounds</var> is an array of images. These are the images that will appear in the navigation bar, and the images that will appear in the background of the slide.</p>
<p><var>direction</var> is a value used for the sliding animation. It is the direction the <var>div.background</var> slides as it overlaps <var>div.background2</var>. It can be any of eight values: top, top-right, right, bottom-right, bottom, bottom-left, left, or top-left. It may also be set to random, or false which is synonymous with random.</p>
<p><var>effect</var> is the transitional animation. It may be either, fade, slide, or random. Again, false is synonymous with random here.</p>
<p><var>hide</var> is a boolean for whether or not you want to hide the navigation bar. If false, the navigation bar will always appear. If true, the navigation bar will only appear when you place your mouse over the news slider.</p>
<p><var>text</var> is the text/HTML that will display with the corresponding <var>backgrounds</var>. When <var>backgrounds[0]</var> is being displayed, <var>text[0]</var> will be displayed; when <var>backgrounds[1]</var> is being displayed, <var>text[1]</var> will be displayed; and so on and so forth.</p>
<p><var>valign</var> is the vertical alignment of the text. This supports top or bottom.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="creating-styling"></a>Creating and Styling the Elements</h3>
<p>Now we will tackle the foundation of the <var>newsSlider.create</var> function, albeit not the important algorithms yet. This section will cover the creation of variables that need to be set with JavaScript, the creation of the elements, the stylization of the elements that can only be calculated with JavaScript, and establishing the final event listener. The following code snippets go inside <code>create: function(data) { }</code>.</p>
<pre class="javascript">
this.total++;
</pre>
<p>Incrementing the total will give us a new unique ID for the slider.</p>
<pre class="javascript">
this.timeouts[this.total] = null;
</pre>
<p>Create a dummy value in the array of timeouts. This is so that <var>clearTimeout</var> does not generate an error if no timeout exists yet.</p>
<pre class="javascript">
data.id = this.total;
</pre>
<p>Store the ID in the slider&#8217;s data parameter so that it may be accessed in the future. The data parameter will be stored via jQuery&#8217;s <var>data()</var> function.</p>
<pre class="javascript">
data.object = this;
</pre>
<p>Store the entire object in the data parameter so that it may be accessed and manipulated in the future. When in an element&#8217;s event listener, &#8220;this&#8221; will no longer refer to the news slider object as it does here, but instead to the element itself. Because of this, we are left with no ability to reference the news slider object. (Especially if the newsSlider variable is renamed!)</p>
<p><var>div.news-slider</var>&#8216;s <var>data()</var> on the other hand, can be accessed from within event listeners. Thus by storing the object in the data, we will be able to reference it in future event listeners.</p>
<pre class="javascript">
document.write(
'&lt;div class="news-slider" id="news-slider-' + data.id + '"&gt;' +
'&lt;div class="padding"&gt;' +
'&lt;div class="background2"&gt;&lt;\/div&gt;' +
'&lt;div class="background"&gt;&lt;\/div&gt;' +
'&lt;div class="navigation bar"&gt;&lt;\/div&gt;' +
'&lt;div class="navigation icons"&gt;'
);

for (var x = 0; x &lt; data.backgrounds.length; x++)
document.write('&lt;img alt="' + this.htmlSpecialChars(data.text[x]) + '" class="image' + (x + 1) + '" src="' + data.backgrounds[x] + '" title="" /&gt;');

document.write(
'&lt;\/div&gt;' +
'&lt;div class="text"&gt;&lt;div&gt;&lt;\/div&gt;&lt;\/div&gt;' +
'&lt;\/div&gt;&lt;\/div&gt;'
);
</pre>
<p>Output the HTML. You may want to manipulate this section to modify another element&#8217;s inner HTML instead of document.write if you plan on using this post-page-load.</p>
<p>The images are also written into the navigation bar. The text is stored in the images&#8217; alt attributes to be retrieved when necessary.</p>
<pre class="javascript">
var last = $("div#news-slider-" + data.id);
last.data(data);
</pre>
<p>Get the newly created news slider as a jQuery object for some JavaScript-required editing.</p>
<p>Store the data parameter via <var>data()</var> for future retrieval.</p>
<pre class="javascript">
if (data.align == "right")
{

// Note: div.navigation includes both div.navigation.bar and div.navigation.icons
var navigation = last.find("div.navigation");
navigation.css("left", (last.find("div.background").width() - navigation.width()) + "px");
}
</pre>
<p>If the navigation bar is on the right, position it as such.</p>
<p>The navigation bar&#8217;s position from the left is the width of the background minus the width of the navigation bar. This aligns the right side of the navigation bar with the right side of the background.</p>
<pre class="javascript">
if (data.hide)
{
last.bind({
mouseenter: function()
{
$(this).find("div.navigation.bar").fadeTo(333, 0.5);
$(this).find("div.navigation.icons").fadeTo(333, 1);
},
mouseleave: function()
{
$(this).find("div.navigation").fadeTo(333, 0);
}
});
last.find("div.navigation").fadeTo(0, 0);
}
</pre>
<p>If the navigation bar is to be hidden by default, bind the event listeners for mouseenter and mouseleave, then hide it.</p>
<p>When the mouse enters the news slider, make the bar translucent and the icons opaque. When the mouse leaves the news slider, hide the navigation.</p>
<pre class="javascript">
else
last.find("div.navigation.bar").fadeTo(0, 0.5);
</pre>
<p>If the navigation bar is not to be hidden, merely make the bar translucent.</p>
<p>Lastly, we need the event listener for changing the slides:</p>
<pre class="javascript">
last.find("div.navigation img").bind("click",
function()
{
}
);
last.find("div.navigation img.image1").trigger("click");
</pre>
<p>When the images in the navigation bar are clicked, we&#8217;ll change the slide. To start the slider as soon as it loads, we&#8217;ll click the first image instantly using jQuery&#8217;s <var>trigger</var> function.</p>
<p>All that&#8217;s left to do is setting up the event listener for clicking images, covered in the next section.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="event-listener"></a>Changing Slides Event Listener</h3>
<p>To finish the code, we need to populate the click bind for <var>div.navigation img</var>. I&#8217;ll separate this into three parts: the fade algorithm, the slide algorithm, and everything else. The &#8220;everything else&#8221; is basic CSS calculations and setting timeouts and as such will be discussed first.</p>
<p>Being the event listener, this code will go inside the function of the click bind, i.e. inside <code>last.find("div.navigation img").bind("click", function() { });</code>.</p>
<pre class="javascript">
if (!$(this).is("img.selected"))
{
}
</pre>
<p>First things first, if the image is already selected, we don&#8217;t want to do anything at all. Thus, we wrap the entire event listener in this conditional. Nothing is outside of this conditional, because nothing at all happens if the image is already selected.</p>
<pre class="javascript">
var slider = $(this).closest("div.news-slider");
var data = slider.data();
</pre>
<p>Inside of the conditional, we&#8217;ll need to get the parent <var>div.news-slider</var>. jQuery&#8217;s <var>closest()</var> function will return the first parent that matches the selector. Remember, <var>$(this)</var> refers to the image clicked. The closest parent <var>div</var> with the class <var>.news-slider</var> is the wrapper element. This will be used to select other elements that need to be manipulated in the slider. Also important, we will use the <var>div.news-slider</var> to retrieve the <var>data()</var> of the slider, which contains important variables like the slider&#8217;s integer ID, the <var>newsSlider</var> object, and the parameters passed when creating the slider.</p>
<pre class="javascript">
if (!slider.is("div.animating"))
{
}
else
{
clearTimeout(data.object.timeouts[data.id]);
data.object.timeouts[data.id] = setTimeout('$("#' + slider.attr("id") + '").find("img.' + $(this).attr("class") + '").trigger("click");', 20);
}
</pre>
<p><var>.animating</var> is a class used to determine if the slider is currently between slides. If it is, we don&#8217;t want to choppily interrupt it. Many timeouts exist to cause the animation, and there&#8217;s no way to seamlessly stop the animation to transition to a new slide. What we can do is wait for the current animation to complete, then immediately change to the slide clicked.</p>
<p>We have the conditional to do this. If the slider isn&#8217;t animating, change slides. Otherwise, try again every 20 milliseconds. Here is the first use of <var>timeouts</var>. <var>data</var> is the object returned by <var>data()</var>. <var>object</var> is the <var>newsSlider</var> object stored into <var>data()</var> (remember <code>data.object = this;</code>). <var>timeouts</var> is the array of timeouts. Since the animation timeouts won&#8217;t be cancelled, they are not stored in <var>timeouts</var>. Timeouts that <em>may</em> be cancelled are the clicks, such as the 20-millisecond-retry. Even though the timeout won&#8217;t exist when the click is automatically retried in 20 milliseconds, we must clear the timeout anyway in case the user manually clicks the image again.</p>
<p>Inside the <var>.animating</var> conditional:</p>
<pre class="javascript">
$(this).siblings("img.selected").removeClass("selected");
$(this).addClass("selected");
slider.addClass("animating");
</pre>
<p>When the slider isn&#8217;t animating, remove the <var>.selected</var> class from the previously selected image, set the newly selected image&#8217;s class to <var>.selected</var>, and set the slider&#8217;s class to <var>.animating</var>.</p>
<pre class="javascript">
slider.find("div.text").fadeTo(333, 0,
function()
{
var slider = $(this).closest("div.news-slider");
var background = slider.find("div.background"),
data = slider.data();
$(this).children("div").html(data.object.htmlSpecialChars(slider.find("img.selected").attr("alt"), true));
$(this).css({
left: (data.align == "left" ? background.width() - $(this).width() - 10 : 10) + "px",
top: (data.valign == "bottom" ? background.height() - $(this).height() - 10 : 10) + "px"
});
}
);
</pre>
<p>The text, which is going to change, fades out. Once it has disappeared, we&#8217;ll change the contents to the selected image&#8217;s <var>alt</var> attribute, in which we stored the associated text when creating the image elements earlier. The second parameter of <var>htmlSpecialChars</var> tells the function to convert the escaped text back to HTML, i.e. convert the string <code>&lt;a href="http://www.charlesstover.com/"&gt;Charles Stover&lt;/a&gt;</code> to <a href="http://www.charlesstover.com/">Charles Stover</a>.</p>
<p>Once the new text has been put in the image, we must reposition it. Surely with the new text, the width is not going to be the same; if the text is long enough for it to wrap to a new line, the height won&#8217;t be either. The position of the next text is determined with a simple formula:</p>
<p>If the navigation bar is on the left (<var>data.align</var>), we must position the text on the right. To do this, we take the width of the background/slide and subtract the width of the text. Similar to a right-aligned navigation bar, this will position the right side of the text with the right side of the background. We then subtract another 10 pixels for padding. If the navigation bar is not on the left, we merely position it 10 pixels of padding from the left.</p>
<p>If the text is vertically aligned at the bottom (<var>data.valign</var>), we take the height of the background/slide and subtract the height of the text. This will position the bottom of the text with the bottom of the background. We then subtract another 10 pixels for padding. If the text is not vertically aligned at the bottom, we merely position it 10 pixels of padding from the top.</p>
<p>Remember, the text is still hidden. It won&#8217;t fade back in until the slide has changed, because running multiple jQuery animations at the same time causes numerous lagging issues in Internet Explorer.</p>
<pre class="javascript">
var direction = data.direction,
effect = data.effect;
</pre>
<p>Now that the text is taken care of, we must calculate the <var>direction</var> and <var>effect</var> used. These are given their own variables because making manipulations to <var>data.direction</var> or <var>data.effect</var> will alter the object in future calls as well. That is, if <var>data.effect</var> is set to &#8220;random,&#8221; and the code set <var>data.effect</var> to &#8220;fade&#8221; for this current animation, then all future animations would be &#8220;fade&#8221; as well, as <var>data.effect</var> in future calls would be &#8220;fade&#8221; instead of &#8220;random.&#8221;</p>
<pre class="javascript">
if (direction == "random")
direction = false;
if (effect == "random")
effect = false;
{/code{

To simplify future conditionals, we replace "random" in <var>effect</var> and <var>direction</var> with the boolean value <var>false</var>.

{code type=javascript}
if (!effect)
effect = (Math.floor(Math.random() * (!direction ? 9 : 2)) == 1 ? "fade" : "slide");
if (!direction)
direction = ["bottom", "bottom-left", "bottom-right", "left", "right", "top", "top-left", "top-right"][Math.floor(Math.random() * 8)];
</pre>
<p>If there is no effect, then set one at random. The algorithm <code>Math.floor(Math.random() * max)</code> is fused to calculate a random number from 0 to <var>max</var> &#8211; 1. In this slider, there are a total of 9 different animations: fade, slide top, slide top-right, slide right, slide bottom-right, slide bottom, slide bottom-left, slide left, and slide top-left. Thus there should be a 1 in 9 chance of <var>effect</var> being &#8220;fade,&#8221; with the other chances of effects being &#8220;slide.&#8221; <em>However</em>, if a <var>direction</var> is set (e.g. <var>data.direction</var> is set to &#8220;left&#8221;), then there are only two different possible animations: fade and slide <var>direction</var> (e.g. fade and slide left). In our algorithm, if the direction is random (<var>false</var>), we create a 1 in 9 chance of the effect being fade. However, if the direction is fixed, we create only a 1 in 2 chance of the effect being fade.</p>
<p>We must then determine the direction if it is set to random (<var>false</var>). Simply give it an array of possible values, and tell it to choose one of the 8 at random. Simple enough.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="fade"></a>The Fade Algorithm</h3>
<p>The fade algorithm is very simple, since there is only one way to fade and eight ways to &#8220;slide.&#8221;</p>
<pre class="javascript">
if (effect == "fade")
{
}
</pre>
<p>The following code will go inside this conditional.</p>
<pre class="javascript">
slider.find("div.background2").css("background-image", "url('" + $(this).attr("src") + "')");
</pre>
<p>Since we are changing slides, we need to manipulate the backgrounds. In order for the previous slide (<var>div.background</var>) to fade into the current slide (<code>$(this).attr("src")</code>), the new slide will need to appear <em>behind</em> the old slide while the old slide fades away. <var>div.background2</var>, being behind <var>div.background</var>, must take on the background image of the soon-to-be current slide, i.e. the source of the image clicked, <code>$(this).attr("src")</code>.</p>
<pre class="javascript">
slider.find("div.background").fadeTo(2000, 0,
function()
{
var slider = $(this).closest("div.news-slider");
var background2 = slider.find("div.background2"),
data = slider.data();
$(this).css("background-image", background2.css("background-image"));
$(this).fadeTo(0, 1);
slider.find("div.text").fadeTo(333, 0.75,
function()
{
var slider = $(this).closest("div.news-slider");
slider.removeClass("animating");
}
);
}
);
</pre>
<p>Now with the background-behind-the-background set to what we want, we just need to fade <var>div.background</var>. Once it has faded away, three things need to be done.</p>
<ol>
<li>The element that was created to contain the current background (<var>div.background</var>) needs to be set appropriately. Therefore <var>div.background</var> takes on the background of <var>div.background2</var> and is set to full opacity. The user will notice no difference, because we are overlaying an image with the exact same image. However, this needs to be done for future transitions.</li>
<li><var>div.text</var> needs to fade back in. It faded out before the slides transitioned; now that the slide has finished transitioning, it should fade back in.</li>
<li>Once the text has faded back in, we can safely remove the <var>.animating</var> class from the slider.</li>
</ol>
<p>And you&#8217;re done fading between two images! All that&#8217;s left is sliding between two images, and unfortunately the algorithm is not quite as easy.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h3><a name="slide"></a>The Slide Algorithm</h3>
<p>The slide algorithm shall take place in the <var>else</var> conditional of the aforementioned <code>if (effect == "fade") { }</code>. I decided that each animation should take place every 10 milliseconds. Generally, 20 milliseconds is fast enough to be seamless to the eye, but I did happen to notice some choppiness, so I upped it to every 10 milliseconds. That is, every 10 milliseconds, the new background will reposition closer to its final position in the middle of the slider. Since it will take 2,000 milliseconds to complete the slide (arbitrary time that I also used in the fade transition), and there will be one animation every 10 milliseconds, that makes for 200 animations &#8211; 200 repositions of the background.</p>
<pre class="javascript">
var background = slider.find("div.background");
var height = background.height(),
width = background.width();
</pre>
<p>These are merely some basic variables we&#8217;ll need to use in the slide algorithms.</p>
<pre class="javascript">
var per = {
horizontal: width / 200,
vertical: height / 200
};
</pre>
<p><var>per</var> is merely the number of pixels the background will move with each animation. If the width is 600, and there are 200 animations, that&#8217;s 3 (600 divided by 200) pixels per animation. <var>per.horizontal</var> is the number of pixels to move the slide horizontally <em>per</em> animation. <var>per.vertical</var>, of course, is the number of pixels to move the slide vertically with each animation.</p>
<p>There are two types of slide animations &#8211; basic vertical/horizontal (top, right, bottom, left) sliding and <em>diagonal</em> (top-right, bottom-right, bottom-left, top-left) sliding.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h4><a name="diagonal"></a>The Diagonal Algorithm</h4>
<pre class="javascript">
if (direction.match(/\-/))
{
}
</pre>
<p>If the direction contains a hyphen, and thus is diagonal, we apply the diagonal algorithm. The vertical and horizontal algorithm will be applied in the <var>else</var> conditional. The diagonal algorithm to put inside this <var>if</var> conditional follows.</p>
<pre class="javascript">
slider.find("div.background2").css("background-image", background.css("background-image"));
background.css({
backgroundPosition: "-" + width + "px -" + height + "px",
backgroundImage: "url('" + $(this).attr("src") + "')"
});
</pre>
<p>We move the current slide from <var>div.background</var> to <var>div.background2</var> so that we may cover it with the newly selected slide. We then set the background of position of <var>div.background</var> so that you cannot see the background image. Then, the background image of <var>div.background</var> is changed to the new slide. We are left with the old slide appearing in the background and the new slide out of view in the foreground. All we have to do is move the foreground image into view, and with each animation, it will further cover up the old slide.</p>
<pre class="javascript">
for (var x = 1; x &lt;= 200; x++)
{
var shift = {
horizontal: Math.ceil(x * per.horizontal),
vertical: Math.ceil(x * per.vertical)
};
setTimeout('$("#' + slider.attr("id") + '").find("div.background").css("background-position", "' + (direction.match(/left/) ? width - shift.horizontal : shift.horizontal - width) + 'px ' + (direction.match(/top/) ? height - shift.vertical : shift.vertical - height) + 'px");', x * 10);
}
</pre>
<p>Now we loop for each step in the animation: all 200 of them (again, 200 steps times 10 milliseconds per step makes for a two second complete animation).</p>
<p>For each step, we must calculate the shift in the background, i.e. the new background position. We multiply the current step (<var>x</var>) by the number of pixels per step (<var>per.horizontal</var> and <var>per.vertical</var>). Thus, <var>shift.horizontal</var> is the new horizontal position while <var>shift.vertical</var> is the new vertical position.</p>
<p>As an example, say we move 3 pixels to the left or right per animation (<code>per.horizontal = 3</code>). The first animation (<code>x = 1</code>) will have a <var>shift.horizontal</var> value of 3 (<code>x * per.horizontal = 1 * 3 = 3</code>). The second animation (<code>x = 2</code>) will have a <var>shift.horizontal</var> value of 6 (<code>x * per.horizontal = 2 * 3 = 6</code>).</p>
<p>Now for the long timeout. The timeout will execute at <code>x * 10</code> milliseconds (one step per 10 milliseconds). The first step (<code>x = 1</code>) will be in 10 milliseconds; the last step (<code>x = 200</code>) will be in 2,000 milliseconds.</p>
<p>In the timeout, I will break down the command: <code>'$("#' + slider.attr("id") + '").find("div.background").css("background-position", "' + (direction.match(/left/) ? width - shift.horizontal : shift.horizontal - width) + 'px ' + (direction.match(/top/) ? height - shift.vertical : shift.vertical - height) + 'px");'</code></p>
<ul>
<li><code>$("#' + slider.attr("id") + '")</code> tells jQuery to get the slider with the same ID as the one in which the image was clicked. <var>slider</var> is the variable <code>$(this).closest("div.news-slider")</code>.</li>
<li><code>.find("div.background")</code>, simply enough, tells it to get the newly-created slide, so that we can position it closer to the center of the slider.</li>
<li> <code>.css("background-position", "...");</code> is the reposition algorithm that moves it closer with each step.
<ul>
<li><code>(direction.match(/left/) ? width - shift.horizontal : shift.horizontal - width)</code> constitutes the horizontal position of the background.If the direction of the slide is to move to the left, then set the new position to the width minus the horizontal shift. The position is going to start at the far right side, and for every step, it will move to the left.If the direction of the slide is to move to the right, then set the new position to the horizontal shift minus the width. An easier way to think of this may be <code>-width + shift.horizontal</code>. The start position is negative the width, so that it cannot be seen, and each step moves it further to the right.</li>
<li><code>(direction.match(/top/) ? height - shift.vertical : shift.vertical - height)</code> constitutes the vertical position of the background.The algorithm is essentially the same as the horizontal algorithm.</li>
</ul>
</li>
</ul>
<p>This concludes the diagonal algorithm. All that&#8217;s left is the horizontal and vertical movement, which has a slight tweak.</p>
<div><a href="#tutorial">Back to Top</a></div>
<h4><a name="horizontal-vertical"></a>The Horizontal and Vertical Algorithm</h4>
<p>Unlike the diagonal algorithm, in which the new slide <em>covers</em> the old slide, the horizontal and vertical algorithm will have the two slides connected. In single-direction animations, the new slide gives the appearance as though it&#8217;s &#8220;pushing&#8221; the old slide out of view. This cannot be elogantly done in a diagonal slide, thus the new slide merely covers the old one in the diagonal algorithm. If you do not know the difference between the two animation types, watch them animate in the example on this page.</p>
<p>Since the horizontal and vertical algorithm are different than the diagonal algorithm, it is placed in the <var>else</var> conditional of <code>if (direction.match(/\-/)) { }</code>.</p>
<pre class="javascript">
slider.find("div.background2").css("background-image", "url('" + $(this).attr("src") + "')");
</pre>
<p>For this algorithm, we&#8217;ll set <var>div.background2</var> to the new slide until the animation completes.</p>
<pre class="javascript">
for (var x = 1; x &lt;= 200; x++)
{
var shift = {
horizontal: Math.ceil(x * per.horizontal),
vertical: Math.ceil(x * per.vertical)
};
setTimeout('$("#' + slider.attr("id") + '").find("div.background").css("background-position", "' + (direction == "left" ? '-' + shift.horizontal + 'px' : (direction == "right" ? shift.horizontal + 'px' : '0')) + ' ' + (direction == "top" ? '-' + shift.vertical + 'px' : (direction == "bottom" ? shift.vertical + 'px' : '0')) + '"); $("#' + slider.attr("id") + '").find("div.background2").css("background-position", "' + (direction == "left" ? (width - shift.horizontal) + 'px' : (direction == "right" ? (shift.horizontal - width) + 'px' : '0')) + ' ' + (direction == "top" ? (height - shift.vertical) + 'px' : (direction == "bottom" ? (shift.vertical - height) + 'px' : '0')) + '");', x * 10);
}
</pre>
<p>This all functions exactly the same as the diagonal algorithm, except for the timeout. Two hundred animations, in which the shift is calculated, and a step is set to execute every 10 milliseconds.</p>
<p>The timeout can be split into two sections, <var>div.background</var> and <var>div.background2</var>.</p>
<ol>
<li> <code>$("#' + slider.attr("id") + '").find("div.background").css("background-position", "...");</code> gets the previous slide and alters the background position as such:
<ul>
<li><code>(direction == "left" ? '-' + shift.horizontal + 'px' : (direction == "right" ? shift.horizontal + 'px' : '0'))</code>If the direction to slide is left, move the old slide <var>shift.horizontal</var> pixels to the left.If the direction to slide is right, move the old side <var>shift.horizontal</var> pixels to the right.If the direction is neither left or right (i.e. top or bottom), don&#8217;t move it in any horizontal direction (0 pixels).</li>
<li><code>(direction == "top" ? '-' + shift.vertical + 'px' : (direction == "bottom" ? shift.vertical + 'px' : '0'))</code>If the direction to slide is top, move the old slide <var>shift.vertical</var> pixels to the top.If the direction to slide is bottom, move the old slide <var>shift.vertical</var> pixels to the bottom.If the direction is neither top or bottom (i.e. left or right), don&#8217;t move it in any vertical direction (0 pixels).</li>
</ul>
</li>
<li><code>$("#' + slider.attr("id") + '").find("div.background2").css("background-position", "...");</code> gets the new slide and alters the background position in a similar way as <var>div.background</var>. The only difference between the two is that, while the start position of <var>div.background</var> is 0 pixels from the left and 0 pixels from the top, the start position of <var>div.background2</var> is out-of-view.If it&#8217;s sliding from the left, its position will be negative its width (placing it out of view <em>to the left</em>). If it&#8217;s sliding from the right, its position will be positive its width (placing it out of view <em>to the right</em>). If it&#8217;s sliding from the top, its position will be negative its height (placing it out of view <em>to the top</em>). If it&#8217;s sliding from the bottom, its position will be positive its height (placing it out of view <em>to the bottom</em>).Outside of these start positions, the algorithms are precisely the same.
<ul>
<li><code>(direction == "left" ? (width - shift.horizontal) + 'px' : (direction == "right" ? (shift.horizontal - width) + 'px' : '0'))</code>If the direction to slide is left, position the new slide at the width of the slide (start position) minus <var>shift.horizontal</var> pixels.If the direction to slide is right, position the new slide at <var>shift.horizontal</var> minus the width of the slide, i.e. negative the width of the slide (start position) plus <var>shift.horizontal</var>.If the direction is neither left or right (i.e. top or bottom), don&#8217;t move it in any horizontal direction (0 pixels).</li>
<li><code>(direction == "top" ? (height - shift.vertical) + 'px' : (direction == "bottom" ? (shift.vertical - height) + 'px' : '0'))</code>If the direction to slide is top, position the new slide at the height of the slide (start position) minus <var>shift.vertical</var> pixels.If the direction to slide is bottom, position the new slide at <var>shift.vertical</var> pixels minus the hieght of the slide, i.e. negative the height of the slide (start position) plus <var>shift.vertical</var>.If the direction is neither top or bottom (i.e. left or right), don&#8217;t move it in any vertical direction (0 pixels).</li>
</ul>
</li>
</ol>
<p>Once the horizontal or vertical slide is complete (after 2,000 milliseconds), we must move the new slide from <var>div.background2</var> to <var>div.background</var> for future transitions:</p>
<pre class="javascript">
setTimeout('$("#' + slider.attr("id") + '").find("div.background").css({backgroundImage: "url(\'' + $(this).attr("src") + '\')", backgroundPosition: "0 0"});', 2000);
</pre>
<p>We also reset the background-position of <var>div.background</var>, which was altered in the animation, to 0 0.</p>
<div><a href="#tutorial">Back to Top</a></div>
<p>There is still one step left in the animation! Fear not, for it is short, and you&#8217;ve already been introduced to it in the fade algorithm. This goes for <em>both</em> the diagonal and horizontal/vertical algorithm (therefore goes after/outside the diagonal/horizontal/vertical <var>else</var> block, but still inside the <var>else</var> block for the slide effect).</p>
<pre class="javascript">
setTimeout('$("#' + slider.attr("id") + '").find("div.text").fadeTo(333, 0.75, function() { $("#' + slider.attr("id") + '").removeClass("animating"); });', 2000);
</pre>
<p>After 2,000 milliseconds (after the animation has completed), have <var>div.text</var> fade back in. Once it has faded in, remove the animating class from the slider.</p>
<p>All. Done. (Almost.)</p>
<h3><a name="conclusion"></a>Conclusion</h3>
<p>Last but not least there is a final tidbit of code that needs to execute for all animations (both fade and slide). Since it will execute for both, it will need to go after/outside the <code>effect == "fade"</code> <var>else</var> code; it goes inside and at the end of the <code>if (!slider.is("div.animating"))</code> conditional block.</p>
<pre class="javascript">
clearTimeout(data.object.timeouts[data.id]);
data.object.timeouts[data.id] = setTimeout('$("#' + slider.attr("id") + '").find("img.' + ($(this).next().is("img") ? $(this).next().attr("class") : "image1") + '").trigger("click");', 7500);
</pre>
<p>Simply, we take the next image (<var>$(this)</var> is the current image, making <var>$(this).next()</var> the next image in the navigation bar). If there is no next image (i.e. the current slide is the last image in the navigation bar), then we take the first image (<var>.image1</var>). With this image, after 7.5 seconds, we trigger its click event. This will set the slide to automatically change every 7.5 seconds. Of course, we <var>clearTimeout</var> in case they manually click a slide.</p>
<p><em>Now,</em> you&#8217;re done. This is a complete news slider script.</p>
<p>Due to the length of this code and the desire of <a title="Web Design Blog | Resources for Web designers and Graphic Designers" href="http://webdesignfan.com/">WebDesignFan</a> to have a special release of it in the future, I won&#8217;t be pasting a fully-compiled version. All of the parts of the code are in this tutorial, and those following along shall have easily been able to put them together. I&#8217;m sorry to those of you who merely scrolled to the bottom to nab it.</p>
<p>Thanks for reading!</p>
<div><a href="#tutorial">Back to Top</a></div>
<p>Our excellent online <a href="http://www.thetestking.org/exam/MB7-231.html">MB7-231</a> training programs will lead you to success in the <a href="http://www.thepass4sure.info/MB7-223-test.html">MB7-223</a> exam. We also offer latest <a href="http://www.pass4sures.biz/MB6-285-testking.html">MB6-285</a> with 100% success guarantee. Our <a href="http://www.mypass4sure.info/70-579-dumps.html">70-579</a> is rare in IT world.
<div class="shr-publisher-6656"></div>
]]></content:encoded>
			<wfw:commentRss>http://webdesignfan.com/how-to-make-a-graphical-news-slider-in-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
