Title: JavaScript Suggestion
Last modified: August 20, 2016

---

# JavaScript Suggestion

 *  [Bambalazs](https://wordpress.org/support/users/bambalazs/)
 * (@bambalazs)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascript-suggestion/)
 * Hi guys!
 * First of all thank you for this really great plugin. Works good. But I found 
   some disturbing bugs, such as high cpu usage and big white space between ending
   and staring.
    So I decided to help you to improve this plugin and I merged liScroll
   1.0 and [webTicker 1.3](https://raw.github.com/jonmifsud/Web-Ticker/master/jquery.webticker.js).
   Here is the right and working script:
 *     ```
       jQuery.fn.liScroll = function(settings) {
       		settings = jQuery.extend({
       		travelocity: 0.05,
       		direction: 1,
       		moving: true
       		}, settings);
       		return this.each(function(){
       				var $strip = jQuery(this);
       				$strip.addClass("newsticker")
       				var stripWidth = 0;
       				var $mask = $strip.wrap("<div class='mask'></div>");
       				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");
       				$strip.find("li").each(function(i){
       					stripWidth += jQuery(this, i).outerWidth(true);
       				});
       				$strip.width(stripWidth+200);//20 used for ie9 fix
       				function scrollnews(spazio, tempo){
       					if (settings.direction == 1)
       						$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){
       							$strip.children().last().after($strip.children().first());
       							var first = $strip.children().first();
       							var width = first.outerWidth(true);
       							var defTiming = width/settings.travelocity;
       						//$strip.css("left", left);
       							$strip.css("left", '0');
       							scrollnews(width, defTiming);
       						});
       					else
       						$strip.animate({right: '-='+ spazio}, tempo, "linear", function(){
       							$strip.children().last().after($strip.children().first());
       							var first = $strip.children().first();
       							var width = first.outerWidth(true);
       							var defTiming = width/settings.travelocity;
       							//$strip.css("left", left);
       							$strip.css("right", '0');
       							scrollnews(width, defTiming);
       						});
       				}
   
       				var first = $strip.children().first();
       				var travel = first.outerWidth(true);
       				var timing = travel/settings.travelocity;
       				scrollnews(travel, timing);
       				$strip.hover(function(){
       					jQuery(this).stop();
       				},
       				function(){
       						var offset = jQuery(this).offset();
       						var first = $strip.children().first();
       						var width = first.outerWidth(true);
       						var residualSpace;
       						if (settings.direction == 1) residualSpace = parseInt(jQuery(this).css('left').replace('px',''))+ width;
       						else residualSpace = parseInt(jQuery(this).css('right').replace('px',''))+ width;
       						var residualTime = residualSpace/settings.travelocity;
       						scrollnews(residualSpace, residualTime);
       				});
       		});
       };
       ```
   
 * Use it with joy! 😉
 * [http://wordpress.org/extend/plugins/wp-stock-ticker/](http://wordpress.org/extend/plugins/wp-stock-ticker/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [tamiesimpson](https://wordpress.org/support/users/tamiesimpson/)
 * (@tamiesimpson)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascript-suggestion/#post-3537896)
 * Thanks for this update, but how can it be used?
 *  [tamiesimpson](https://wordpress.org/support/users/tamiesimpson/)
 * (@tamiesimpson)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascript-suggestion/#post-3537897)
 * I figured it out, I just had to replace the contents of jquery.li-scroller.1.0.
   js
 * Thanks again, great job!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘JavaScript Suggestion’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-stock-ticker_fffefe.svg)
 * [WP Stock Ticker](https://wordpress.org/plugins/wp-stock-ticker/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-stock-ticker/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-stock-ticker/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-stock-ticker/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-stock-ticker/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-stock-ticker/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 2 replies
 * 2 participants
 * Last reply from: [tamiesimpson](https://wordpress.org/support/users/tamiesimpson/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/javascript-suggestion/#post-3537897)
 * Status: not resolved