Posted By

DrewDouglass on 08/05/09


Tagged

javascript jquery


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

svnlto
legacye
Onfire60
GandalfGrey
qubestream


jQuery Link Nudge Plugin


 / Published in: JavaScript
 

URL: http://dev-tips.com/featured/link-nudge-jquery-plugin

Plugin Source.

  1. (function($){
  2.  
  3. //Define the plugin, named 'linkNudge'
  4. $.fn.linkNudge = function(params){
  5.  
  6. //set default parameters
  7. params = $.extend({
  8. padding: 20,
  9. elapseTime: 300,
  10. returnPadding: 0}, params);
  11.  
  12. //Traverse every node passed
  13. this.each(function(){
  14.  
  15. //Define this as a single object
  16. var $t = $(this);
  17.  
  18. //Proceed to nudge on hover
  19. $t.hover(function(){
  20. $t.stop().css('cursor', 'pointer').animate({paddingLeft: params.padding}, params.elapseTime);
  21. }, function(){
  22. $t.stop().animate({paddingLeft: params.returnPadding}, params.elapseTime);
  23. });
  24.  
  25. });
  26.  
  27. return this;//Allow for chaining.
  28. };
  29.  
  30. })(jQuery);

Report this snippet  

You need to login to post a comment.