Smooth Ticker

a place to get help

Moderator: 1.2 Moderators

Forum rules
  • Every time you need help create a new thread (but please use the search function before, as your problem maybe has already been solved)
  • use code highlighting (help)
  • After your problem has been solved you have to rename the subject to "[solved] <Topicname>" AND set the Topic icon as solved (the green check)

Smooth Ticker

Postby bionicoz on Wed Mar 03, 2010 3:47 pm

Hi all, I really hate the way that (probably most of) horizontal tickers start/stop on mouseover, so i tryied to code my own one. Here
there is what I've done, but I'm not satisfied. First, I cannot figure how to repeat the loop when arrived at the end of the <ul> (I've tryied differents way but none works at 100%). Secondarily, I cannot precisely control speed at the end of the accelerating/decelerating transition. (Or i dunno how to do it). This bring some incoherencies between the speeds in the accelerating and the linear phases.
Thanks for any tip/suggestion you would like to tell me. Oh, well, to start animation in mooshell just mousenter/leave the ticker; and sorry for my english :P
Here's the code.
  1. window.addEvent('domready',function(){
  2.     var total=0;
  3.     var ss=0;
  4.     var speed=0.05;
  5.     var wrap=$('wrap');
  6.     var c=$('ppp');
  7.     $$('li').each(function(el){
  8.         total+=el.getSize().x;
  9.     });
  10.    
  11.  
  12.     d=(total-ss)/speed;
  13.     alert(d);
  14.     $('in').setStyle('width',total+'px');
  15.     var myFx1;
  16.     var myFx2 = new Fx.Scroll(wrap, {
  17.         wait:false,
  18.         duration: 50/speed,
  19.         transition: Fx.Transitions.Quad.easeOut}
  20.         );
  21.    
  22.      var myFx3 = new Fx.Scroll(wrap, {
  23.         wait:false,
  24.         duration: 50/speed,
  25.         transition: Fx.Transitions.Quad.easeIn,
  26.          onComplete:function(){
  27.              d=(total-ss)/speed;
  28.              myFx1 = new Fx.Scroll(wrap, {
  29.                 wait:false,
  30.                 duration: d,
  31.                 transition: 'linear',
  32.                  /*onComplete:function(){
  33.                      ss=0;
  34.                      this.set(0,0);
  35.                      this.toRight();}
  36.              */
  37.              }).toRight();
  38.           }
  39.          });
  40.    
  41.     $('wrap').addEvent('mouseover',function(event){
  42.         event = new Event(event).stop();
  43.         myFx1.cancel();
  44.         ss=wrap.getScroll().x;
  45.         c.set('html',ss);
  46.         myFx2.start(ss+50, 0);      
  47.     });
  48.    
  49.         $('wrap').addEvent('mouseleave',function(event){
  50.         myFx2.cancel();
  51.         ss=wrap.getScroll().x;
  52.         c.set('html',ss);
  53.         myFx3.start(ss+50,0);
  54.        
  55.     });
  56. });
bionicoz
 
Posts: 6
Joined: Mon Oct 12, 2009 11:26 pm

Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests