Posted By

Leech on 07/21/06


Tagged

class rotate Objects


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jkochis
vali29


Data Slider v1.0


 / Published in: JavaScript
 

URL: http://jsfromhell.com/classes/data-slider

Auto rotates through objects. Created: 2005.08.08

  1. /**************************************
  2. * Jonas Raoni Soares Silva
  3. * http://www.joninhas.ath.cx
  4. **************************************/
  5.  
  6. (DataSlider = function(onchange, interval, args){ //v1.0
  7. var i = DataSlider.instances = DataSlider.instances || [], o = this;
  8. (o.c = 0, o.timer = null, o.interval = (o.onchange = (o.data = [].slice.call(
  9. arguments, 0)).shift(), o.data.shift()), i[o.index = i.length] = o);
  10. }).prototype = {
  11. stop: function(){
  12. clearTimeout(this.timer);
  13. },
  14. play: function(){
  15. this.timer = setInterval("DataSlider.instances[" + this.index + "].next()", this.interval);
  16. },
  17. show: function(x){
  18. this.c = x; this.onchange(this.data[ x ]);
  19. },
  20. previous: function(){
  21. this.show(this.c > 0 ? --this.c : this.data.length-1);
  22. },
  23. next: function(){
  24. this.show((this.c + 1) % this.data.length);
  25. }
  26. };

Report this snippet  

You need to login to post a comment.