blizzard Posted April 19, 2015 Share Posted April 19, 2015 Hi everyone, Very new here. Although I'm getting quite good with web design, I know nothing avout scripts. I bought a template including this ticker script that I use to display paragraphs of weather texts. I want to modify it to make it stop at mouse over and restart at mouse out for those who read faster or slower than the default speed of the ticker. I put the script here. If you can tip me on what to do, it would be very appreciated. Thanks. (function($) { $.fn.list_ticker = function(options) { var defaults = { speed: 6000, effect: 'slide' }; var options = $.extend(defaults, options); return this.each(function() { var obj = $(this); var list = obj.children(); list.not(':first').hide(); setInterval(function() { list = obj.children(); list.not(':first').hide(); var first_li = list.eq(0) var second_li = list.eq(1) if (options.effect == 'slide') { first_li.slideUp(); second_li.slideDown(function() { first_li.remove().appendTo(obj); }); } else if (options.effect == 'fade') { first_li.fadeOut(function() { second_li.fadeIn(); first_li.remove().appendTo(obj); }); } }, options.speed) }); }; })(jQuery); $(function() { $('#ticker').list_ticker({ speed: 15000, effect: 'fade' }) }); Link to comment Share on other sites More sharing options...
mannemvamsi Posted April 20, 2015 Share Posted April 20, 2015 I made minor modifications to your script. The trick is clearning the timer on mouseover. Recalling the function on mouseout. Maybe there can be better way But this seems like working I made a fiddle. http://jsfiddle.net/mannemvamsi/v3wzj68b/ Link to comment Share on other sites More sharing options...
blizzard Posted April 21, 2015 Author Share Posted April 21, 2015 Wow ! It works perfectly. Thanks you so much ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now