Prototype Ticker - The 08/15 Way ;)
February 26th, 2007
Tags: Dies_und_Das, javascript, opensource, prototypeIch mag Prototype. :)
JAVASCRIPT:
-
var Ticker = Class.create();
-
Ticker.prototype = {
-
messages: new Array(),
-
counter: 0, interval: 0,
-
target: null, source: null,
-
initialize: function(target, source, options)
-
{
-
this.target = $(target);
-
this.source = $(source);
-
this.options = Object.extend({
-
updateRate: 2,
-
duration: 0.5,
-
beforeStart:function(){
-
this.counter++;
-
}.bind(this)
-
}, options || {});
-
-
Element.cleanWhitespace(this.source);
-
$A($(this.source).childNodes).each(function(sel) {
-
this.messages.push(sel.innerHTML.strip());
-
}.bind(this));
-
-
this.start();
-
},
-
start: function()
-
{
-
this.interval = new PeriodicalExecuter(function() {
-
this.target.update(' ').appendChild(Builder.node('span',{style:'opacity:0'}, this.messages[this.counter]));
-
new Effect.Appear(this.target.lastChild, this.options);
-
if(this.counter == this.messages.length){ this.counter = 0;}
-
}.bind(this), this.options.updateRate);
-
},
-
stop: function()
-
{
-
this.interval.stop();
-
}
-
};
Benutzung:
var ticker = new Ticker('ziel', 'quelle', {duration:0.3, updateRate: 3});
Abhängigkeiten:
Prototype.js 1.5.0 und Builder.js, sowie Effects.js von Scriptaculous
Ticker Demo
Download ticker.js
27.02 - fixed IE bug.


February 28th, 2007 at 08:13
March 5th, 2007 at 17:34
October 23rd, 2007 at 11:07
I would like to use this code but when I send to it a html code it doesn't parse it, and it show me the html tags. How can I fix this problem?
July 7th, 2009 at 08:07
July 7th, 2009 at 08:13
Viele Grüsse
Kjell
July 7th, 2009 at 08:15