-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
73 lines (69 loc) · 2.65 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<html>
<head>
<title>APNG test</title>
<script type="text/javascript" src="src/crc32.js"></script>
<script type="text/javascript" src="src/udeferred.js"></script>
<script type="text/javascript" src="src/apng-canvas.js"></script>
</head>
<body id="body">
<img src="test.png" style="width:200px;">
<div>
<button id="stop">stop</button>
<button id="play">play</button>
<p>
<input id="input_goto" value="55" type="text">
<button id="goto">goto</button>
</p>
<p>
<input id="input_playto" value="28" type="text">
<button id="playto">playto</button>
</p>
</div>
<!-- <img src="APNG-cube.png"> -->
<script type="text/javascript">
function $(o){
return document.getElementById(o);
}
for (var i = 0; i < document.images.length; i++) {
var img = document.images[i];
if (/\.png$/i.test(img.src)){
var apng= APNG.animateImage(img);
apng.done(function(ani){
// listen playing,you can get current frame
ani.playing=function(t){
console.log(t)
if(t==20){
ani.stop();
}
}
$("stop").addEventListener("click",function(){
// stop apng
ani.stop().done(function(){
console.log("stop")
});
})
$("play").addEventListener("click",function(){
// play apng
ani.play().done(function(){
console.log("play")
});
});
$("goto").addEventListener("click",function(){
var val=$("input_goto").value;
// goto the frame
ani.goto(parseInt(val)).done(function(){
console.log("goto")
});
});
$("playto").addEventListener("click",function(){
var val=$("input_playto").value;
// playto the frame
ani.playto(parseInt(val)).done(function(){
console.log(ani.nowFrame)
});
});
})
}
}
</script>
</body>