This is how we roll

about 1 year ago - David Crean

var TickerManager = {

ticker: null,

elements: null,

curElement: null,

curElementIndex: 0,

leftPosition: null,

init: function() {

this.ticker = $('ticker');

this.elements = this.ticker.getElementsByTagName('li');

this.leftPosition = YAHOO.util.Dom.getX(this.elements[this.curElementIndex]);

this.addTriggers();

this.animateTicker();

setInterval('TickerManager.animateTicker()', 10000);

},

reorderElements: function(order) {

},

animateTicker: function() {

if(this.curElement) {

//move current element out of the way

var scrollAnim = new YAHOO.util.Motion(this.curElement,{ points: { to: [this.leftPosition,250] } },1, YAHOO.util.Easing.easeOut);

scrollAnim.animate();

var opacityAnim = new YAHOO.util.Anim(this.curElement,{ opacity: { to: 0, from: 1 } },1, YAHOO.util.Easing.easeOut);

opacityAnim.animate();

this.curElementIndex = this.curElementIndex+1

}

this.curElement = this.elements[this.curElementIndex];

this.curElement.style.top = '-40px';

var scrollAnim = new YAHOO.util.Motion(this.curElement,{ points: { to: [this.leftPosition,200] } },1, YAHOO.util.Easing.easeOut);

scrollAnim.animate();

var opacityAnim = new YAHOO.util.Anim(this.curElement,{ opacity: { to: 1, from: 0 } },1, YAHOO.util.Easing.easeOut);

opacityAnim.animate();

},

addTriggers: function() {

var upArrow = $('ticker-up');

var downArrow = $('ticker-down');

YAHOO.util.Event.addListener(upArrow, 'click', TickerManager.reorderElements, 'up');

YAHOO.util.Event.addListener(upArrow, 'click', TickerManager.reorderElements, 'down');

}

}

These things just make sense to me sometimes.

Tags: javascript web design ticker UI

0 Comments on This is how we roll

Leave a Comment

About Me

I'm a UI developer living in Los Angeles with my wife and 5 hell-raising cats.

I will randomly be spouting my random thoughts and highlighting work that I'm proud of, or sometimes, not so proud of.

One aside about this site, I don't go out of my way to hack around IE6 here, I spend enough time doing that day in and day out. It should work reasonably well in modern browers, but I don't go out of my way to hack around fawlty border implementation or lax support for child selectors.