JavaScript 图像动画的小demo

时间:2021-05-26

复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://plete, set a flag to start when it is
if (!this.loaded) this.startOnLoad = true;
else {
// If we haven't looked up the image by id yet, do so now
if (!this.image) this.image = document.getElementById(this.imageId);
// Display the first frame immediately
this._displayNextFrame();
// And set a timer to display subsequent frames
this.timer = setInterval(this._displayNextFrame, this.frameInterval);
}
};

/** Stop an ImageLoop animation */
ImageLoop.prototype.stop = function () {
if (this.timer) clearInterval(this.timer);
this.timer = null;
};

</script>
<script type="text/javascript">
function de() {
var animation = new ImageLoop("loop", 1, ["img/img_01.jpg", "img/img_02.jpg",]);
var sta = document.getElementById("sta");
var stp = document.getElementById("stp");
sta.onclick = function () {
animation.start();
}
stp.onclick = function () {
animation.stop();
}
}
window.onload = function () {
de();
}
</script>
</head>
<body>
<img src="img/img_01.jpg" id="loop" alt="" title="" />
<a href="#" class="de" id="sta">Start</a>
<a href="#" class="de" id="stp">Stop</a>
</body>
</html>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章