Subscribe to our feed...

http://feeds.feedburner.com/design-notes

  • Push Your Designs To Perfection

    goldSCHNITT is a small stand alone application for MAC that helps you apply golden ration to your design. Golden ratio(1.61803) is believed as a ratio of perfection. It has been used by many artists and architects through the history.

    Now we have this small app called goldSCHNITT to help you implement golden ration into your design.

Play with jQuery – infinite loop and hover sliding effect

Under: jQuery 2 comments
Picture 2

Play with jQuery

This is how this “game” works. The flashing text says “LOOK AT ME”. When you hover just underneath the text it reveals a little cartoon girl. It covers the girl again when you move the mouse away quickly. When you click the “LOOK AT ME” text the sliding animation will end. Refresh it if you wanna see the animation again.
To see the Demo


This is how to do it:

Simple HTML

<div id="nav">
<div id="girl">
	<a href="#">LOOK AT ME</a></div>
</div>

CSS to add background image

#nav{background:url(images/girl-11.png) no-repeat;width:150px;height:150px;top:100px;left:400px;position:absolute;}
#gate{position:absolute;background:#fff;width:50px;height:50px;padding:50px;}
#girl a{position:absolute;top:-20px;left:10px;color:pink;font-weight:bold;font-family:arial;text-decoration:none;font-size:18px;}

Javascript

  • jQuery Infinite Loop from line 2 to line 9:basically you make a loop start with show end with hide. Put anything you want in between and put this in a runIt function. This is also useful if you wanna do a warning sign.
  • Sliding effect from line 10 to line 25:This is very similar to my previous tutorial on Make fancy light up RSS button with jQuery I changed fadeTo to slideUp and slideDown, inserted line 21 cause it has slide down from a hiding state.
$(document).ready(function() {
function runIt() {
		$("#girl a").show(100);
		$("#girl a").fadeTo(500,0);
		$("#girl a").fadeTo(500,1);
		$("#girl a").fadeTo(500,0);
		$("#girl a").hide(1, runIt);
		   }
		    runIt();
		$(function () {
			 $('#girl')
			    // create our new span.hover and loop through anchor:
			  .append('<span id="gate" class="hover">').each(function () {
			   var $span = $('&gt; span.hover', this).css('opacity', 1);
			   // when the user hovers in and out
			   $(this).hover(function () {
			    // on hover
			     $span.stop().slideUp(1200);
			      }, function () {
			        // off hover
			 $span.hide();
			$span.slideDown(1500);
			      });
			    });
			});
	 });
</span>

Conclusion

You are welcome to copy the code and experiment with it. I believe the next web trend will be “game like” interactions and jQuery is a great framework to do all sorts of fancy effects. Learn more and prepare yourself for the challenge.

ADD TOAdd To Evernote

If this helps, why not tell your friends?

  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook
  • Technorati
  • Design Float
  • Identi.ca
  • FriendFeed
  • Yahoo! Buzz
  • Ping.fm

2 Responses to “ Play with jQuery – infinite loop and hover sliding effect ”

Leave a Reply

All fields marked with "*" are required.








cakma blog anal sikis porno izle porno izle yusuf yusufs r10 Güncel Blog irc forum irc u>