Created
February 23, 2012 14:25
-
-
Save namusyaka/1893064 to your computer and use it in GitHub Desktop.
ふくさんぶつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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