1/*! 2 * jquery.smartmarquee 3 * 4 * Copyright 2014 stemizer.net ~ nestisamet<a>gmail<d>com 5 * Licensed under the MIT license 6 * http://opensource.org/licenses/mit 7 * 8 * @author Samet TEMIZER 9 * @version 1.0 10 */ 11 12$.fn.smartmarquee = function(vars) { 13 var defaults = { 14 duration: 1000, // animate duration 15 loop : true, 16 interval : 2000, // interval duration 17 axis : "vertical", 18 easing : "linear" // (next ver) 19 }; 20 var options = $.extend(defaults, vars); 21 function marquee(obj) { 22 var self = this; 23 var timer, indexHandle, marginHandle; 24 var container = $(".container",obj); 25 obj.hover( 26 function() { self.stop(); }, 27 function() { self.play(indexHandle,marginHandle);} 28 ); 29 this.play = function(i,margin) 30 { 31 if (!i) i = 0; 32 var _vertical = function() { 33 if (i < container.children().length-1) { 34 var len = container.children().eq(i).height(); // .outerHeight(true) 35 len += (container.children().eq(i).outerHeight(true)-len)/2; 36 if (!margin) { 37 margin = parseInt(container.css("margin-top")) - len; 38 marginHandle = margin; 39 } 40 container.animate({"margin-top":margin+"px"}, options.duration, "linear", function() { 41 timer = setTimeout(function() { 42 self.play(++i); 43 },options.interval); 44 }); 45 indexHandle = i; 46 } 47 else if (options.loop) { 48 container.animate({"margin-top":"0px"}, "linear", function() { 49 setTimeout(function() { self.play(0); },options.interval); 50 }); 51 } 52 }; 53 var _horizontal = function() { 54 if (i < container.children().length-1) { 55 var len = container.children().eq(i).outerWidth(true); 56 if (!margin) { 57 margin = container.css("margin-left").split("px")[0] - len; 58 marginHandle = margin; 59 } 60 container.animate({"margin-left":margin+"px"}, options.duration, "linear", function() { 61 timer = setTimeout(function() { 62 self.play(++i); 63 },options.interval); 64 }); 65 indexHandle = i; 66 } 67 else if (options.loop) { 68 container.animate({"margin-left":"0px"}, "linear", function() { 69 setTimeout(function() { self.play(0); },options.interval); 70 }); 71 } 72 }; 73 (options.axis == "vertical") ? _vertical() : _horizontal(); 74 }; 75 this.stop = function() { 76 clearTimeout(timer); 77 if (container.is(":animated")) container.stop(); 78 }; 79 }; 80 return this.each(function() { 81 var slide = new marquee($(this)); 82 setTimeout(function() { slide.play(); }, options.interval); 83 }); 84};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.