public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<script type="text/javascript">
YUI().use('anim', 'node', function(Y){
Y.one("#footer-newsticker").removeClass("hidden");
var tickernode = Y.one('#footer-newsticker')
/* This gets the max value of scrollLeft quickly, making for smooth
* animation with no delay before the fade and rest.
*/
tickernode.set('opacity', 0);
tickernode.set('scrollLeft', tickernode.get('offsetWidth'));
var maxScroll = tickernode.get('scrollLeft');
tickernode.set('scrollLeft', 0);
tickernode.set('opacity', 1);
 
/* Now set up the animation and events */
var ticker = new Y.Anim({
node: tickernode,
to:{
scroll: function(node) {
return [node.get('scrollLeft') + maxScroll, 0]
}
},
duration: Math.round(100)
}
);
 
var onEndRestart = function() {
this.detach();
this.on('end', onEndScroll);
this.setAttrs({
to:{
scroll: function(node) {
return [node.get('scrollLeft') + maxScroll, 0]
}
},
duration: Math.round(100)
});
this.get('node').set('to', { scroll: [tickernode.get('scrollLeft'), 0] });
 
this.run();
};
 
var onEndFade = function() {
this.detach();
this.on('end', onEndRestart);
this.get('node').set("scrollLeft", 0);
this.setAttrs({
to: { opacity: 1 },
duration: 1
});
this.run();
};
 
var onEndScroll = function() {
this.detach();
this.on('end', onEndFade);
this.setAttrs({
to: { opacity: 0 },
duration: 1
});
this.run();
};
 
 
 
var onHover = function() {
if (ticker.get('running')) {
ticker.pause();
} else {
ticker.run();
}
}
 
ticker.on('end', onEndScroll);
tickernode.on('mouseover', onHover);
tickernode.on('mouseout', onHover);
 
 
tickernode.set('to', { scroll: [tickernode.get('scrollLeft'), 0] });
ticker.run();
});
</script>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.