-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlazyslider.pack.js
More file actions
12 lines (11 loc) · 2.22 KB
/
lazyslider.pack.js
File metadata and controls
12 lines (11 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
/*
* Lazy Slider v0.1
* https://github.com/beatnbite/lazyslider
*
* Copyright 2014, Vyacheslav Petrov
*
* Free for non-commercial use.
* A license fee is required for commercial use.
* Please refer to LICENSE file for details.
*/
!function(a){var b=function(b,c){var d={animationSpeed:700,animationDelay:5e3,easingOut:"swing",easingIn:"swing",captionAnimationSpeed:250,captionAnimationDelay:600,randomStart:!0};a.extend(d,c);var e=a(b),f=[],g=0,h=0;this.run=function(){j();var b=a(".lazyslider-caption",e),c=a(".lazyslider-panes",e);c.hover(function(){clearTimeout(c.t),b.stop().animate({bottom:0},d.captionAnimationSpeed)},function(){c.t=setTimeout(function(){var c=a(".lazyslider-description",b).outerHeight();b.stop().animate({bottom:-c},d.captionAnimationSpeed)},d.captionAnimationDelay)}),k(),l()};var j=function(){e.append('<div class="lazyslider-panes"><div class="lazyslider-first-pane lazyslider-pane"></div><div class="lazyslider-second-pane lazyslider-pane"></div><div class="lazyslider-caption"><div class="lazyslider-background"></div><div class="lazyslider-description"></div></div></div>'),e.addClass("lazyslider"),a(".slide",e).each(function(b){var c=a(this),d=c.data("link");f[b]={url:c.data("src"),width:c.data("width"),height:c.data("height"),alt:a.trim(c.text()),slide:c},d&&(f[b].link=d),g++}),d.randomStart&&(h=Math.floor(Math.random()*g))},k=function(){a(".lazyslider-description",e).text(f[h].alt)},l=function(){m(),setTimeout(n,d.animationDelay)},m=function(){a(".lazyslider-first-pane a, .lazyslider-first-pane img",e).remove(),a(".lazyslider-first-pane",e).append(o(h)),a(".lazyslider-first-pane",e).show(),h++,h>=g&&(h=0),a(".lazyslider-second-pane",e).hide(),a(".lazyslider-second-pane a, .lazyslider-second-pane img",e).remove(),a(".lazyslider-second-pane",e).append(o(h))},n=function(){k(),a(".lazyslider-first-pane",e).fadeOut({duration:d.animationSpeed,easing:d.easingOut}),a(".lazyslider-second-pane",e).fadeIn({duration:d.animationSpeed,easing:d.easingIn,complete:l})},o=function(a){var b=f[a],c='<img src="'+b.url+'" width="'+b.width+'" height="'+b.height+'" alt="'+b.alt+'" />';return"link"in b?'<a href="'+b.link+'">'+c+"</a>":c}};a.fn.lazySlider=function(a){return this.each(function(){var e=new b(this,a);e.run()})}}(jQuery);