/* * jquery scroll follow plugin * @author vince * @email ws.file@gmail.com */ (function(e){var t=this;e.fn.scrollfollow=function(t){var n={init:function(t){o=e.extend({},this.scrollfollow.defaults,t);return this.each(function(){var t=e(this);var n=this;var i=t.offset();var s=o.direction;animate=settimeout(function(){t.css(s=="left"?"left":"right",o.distance+"px");t.css({top:e(window).scrolltop()+o.top}).fadein(300)},o.timer);e(window).scroll(function(){window.console&&console.log(e(window).scrolltop(),i.top);if(e(window).scrolltop()>i.top){r._ani(t,e(window).scrolltop()+o.top)}else{if(e(window).scrolltop()>0){r._ani(t,e(window).scrolltop()+o.top)}else{r._ani(t,o.top)}}})})}};var r={_ani:function(e,t){cleartimeout(animate);animate=settimeout(function(){e.stop(true,true).animate({top:t},o.speed)},o.timer)}};if(n[t]){return n[t].apply(this,array.prototype.slice.call(arguments,1))}else if(typeof t==="object"||!t){return n.init.apply(this,arguments)}else{window.console&&console.error("no method: "+t)}};e.fn.scrollfollow.defaults={top:156,direction:"right",distance:6,speed:450,timer:80,beforeshow:function(){},aftershow:function(){},beforehide:function(){},afterhide:function(){}};e.fn.scrollfollow.settings={}})(jquery)