Skip to content

Instantly share code, notes, and snippets.

@namusyaka
Created February 23, 2012 14:25
Show Gist options
  • Save namusyaka/1893064 to your computer and use it in GitHub Desktop.
Save namusyaka/1893064 to your computer and use it in GitHub Desktop.
ふくさんぶつ
function SlideImage () {
return (this instanceof SlideImage) ? this.init() : new SlideImage();
};
(function (proto) {
proto.init = function () {
this.images = [];
this.display = null;
};
proto.addImage = function (path) {
var img = new Image();
img.src = path;
this.images[this.images.length] = img;
};
proto.run = function (opt_start, opt_goal) {
var start = opt_start || 0
, goal = opt_goal || this.images.length - 1
, images = this.images
, display = this.display;
function timer () {
if(start >= goal)
return;
display.removeChild(display.getElementsByTagName('img')[0]);
display.appendChild(images[start++]);
setTimeout(arguments.callee, 150);
};
setTimeout(timer, 150);
};
})(SlideImage.prototype);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment