シンプルな画像読み込みアニメーションを探しています。キャンバス上の描画とプレーンな Javascript のみを使用する、短くてシンプルなソリューションを見つけたいと思います。
助けてください
シンプルな画像読み込みアニメーションを探しています。キャンバス上の描画とプレーンな Javascript のみを使用する、短くてシンプルなソリューションを見つけたいと思います。
助けてください
Ajaxload.infoやPreloaders.netなどのオンライン ツールで生成されたローディング GIF を使用し、キャンバス要素の前で切り替えることができる div タグに配置します。
その他のスピナー ジェネレーター スクリプトについては、「5 Online Loading AJAX Spinner Generator Tools」を参照してください。
お役に立てれば!
drawProgressIndicator: function(){
var can = this.imgCanvas;
var ctx = this.imgCtx;
ctx.save();
ctx.clearRect(0, 0, can.width, can.height);
ctx.translate(can.width / 2, can.height / 2);
ctx.scale(0.4, 0.4);
ctx.rotate(-Math.PI / 2);
ctx.strokeStyle = "black";
ctx.fillStyle = "white";
ctx.lineWidth = 8;
ctx.lineCap = "round";
var step = this.animationStep;
ctx.fillStyle = "black";
ctx.save();
ctx.rotate(step * Math.PI / 30);
ctx.strokeStyle = "#33ccff";
ctx.fillStyle = "#33ccff";
ctx.lineWidth = 10;
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(68, 0);
ctx.stroke();
ctx.fill();
ctx.restore();
ctx.beginPath();
ctx.lineWidth = 14;
ctx.strokeStyle = 'gray';
ctx.arc(0, 0, 80, 0, Math.PI * 2, true);
ctx.stroke();
ctx.restore();
this.animationStep += 1;
},
この記事: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Basic_animationsは、自分のアニメーションを描くのに役立ちました。
これを試してください.. http://jsfiddle.net/swarnendu/Ky25d/
<html>
<head>
<style type="text/css">
#layer6,#layer7,#layer8{position: absolute;left: 0px;top: 0px;}
.anim_8{-webkit-animation-duration: 1.5s;-webkit-animation-iteration-count:infinite;-webkit-transform-origin:25px 25px;-webkit-animation-name:animation_6;-webkit-animation-timing-function: linear;
-moz-animation-timing-function: linear; -moz-animation-duration: 1.5s; -moz-animation-name: animation_6; -moz-transform-origin:25px 25px; -moz-animation-iteration-count:infinite ;
-o-animation-timing-function: linear; -o-animation-duration: 1.5s; -o-animation-name: animation_6; -o-transform-origin:25px 25px; -o-animation-iteration-count:infinite ;}
@-webkit-keyframes animation_6{
0%{ -webkit-transform: rotate(0deg) ;}
100%{ -webkit-transform: rotate(360deg) ;}
}
@-o-keyframes animation_6{
0%{ -o-transform: rotate(0deg) ;}
100%{ -o-transform: rotate(360deg) ;}
}
@-moz-keyframes animation_6{
0%{ -moz-transform: rotate(0deg) ;}
100%{ -moz-transform: rotate(360deg) ;}
}
</style>
<script type="text/javascript">
window.addEventListener("load",draw_canvas,false) ;
function draw_canvas()
{
var c6=document.getElementById("layer6");var ctx6=c6.getContext("2d"); ctx6.fillStyle="#FF000
これは、javascript と canvas- animationのみを使用したアニメーションです。この アプリケーションcanvimを使用して作成されました。このヘルプ ファイルはここにあります。
ただし、画像を使用しておらず、単純ではないため、探しているものではない場合があります。
私が考えることができる他の唯一の方法は、context.drawImageをsetTimeoutとともに使用して、一連の画像を次々にロードすることです
または、以下のコードのように、キャンバスでgif画像を使用するだけです
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function main() {
img=document.getElementById("anigif");
Ani=$("ani");
Ani.width=500;
Ani.height400;
Ani.ctx=Ani.getContext('2d');
Ani.ctx.drawImage(img,0,0)
}
</script>
</head>
<body onload="main()">
<img id="anigif" src="http://www.mathworks.com/matlabcentral/fx_files/21944/2/DancingPeaks.gif">
<canvas id="ani"></canvas>
</body>
</html>
html5 キャンバスを使用した単純なロード アニメーションを探している場合は、ここにあります.. http://jsfiddle.net/swarnendu/urV4p/
<html>
<head>
<style type="text/css">
#d1,#ci1,#ci2,#ci3{position:absolute;top:0px;left:0px}
.cc2{ -webkit-animation-duration: 1s; -webkit-animation-name: loading2w; -webkit-animation-iteration-count:infinite; -moz-animation-duration: 1s; -moz-animation-name: loading2m; -moz-animation-iteration-count:infinite; -o-animation-duration: 1s; -o-animation-name: loading2o; -o-animation-iteration-count:infinite;}
.cc3{ -webkit-animation-duration: 1s; -webkit-animation-name: loading3w; -webkit-animation-iteration-count:infinite; -moz-animation-duration: 1s; -moz-animation-name: loading3m; -moz-animation-iteration-count:infinite; -o-animation-duration: 1s; -o-animation-name: loading3o; -o-animation-iteration-count:infinite;}
@-webkit-keyframes loading2w{
0%{visibility:hidden;}
33%{visibility:hidden;}
33.33%{visibility:visible;}
100%{visibility:hidden;}
}
@-moz-keyframes loading2m{
0%{visibility:hidden;}
33%{visibility:hidden;}
33.33%{visibility:visible;}
100%{visibility:hidden;}
}
@-o-keyframes loading2o{
0%{visibility:hidden;}
33%{visibility:hidden;}
33.33%{visibility:visible;}
100%{visibility:hidden;}
}
@-webkit-keyframes loading3w
{
0%{visibility:hidden;}
66.33%{visibility:hidden;}
66.67%{visibility:visible;}
100%{visibility:hidden;}
}
@-moz-keyframes loading3m
{
0%{visibility:hidden;}
66.33%{visibility:hidden;}
66.67%{visibility:visible;}
100%{visibility:hidden;}
}
@-o-keyframes loading3o
{
0%{visibility:hidden;}
66.33%{visibility:hidden;}
66.67%{visibility:visible;}
100%{visibility:hidden;}
}
</style>
<script type="text/javascript">
window.addEventListener("load",win_load,false);
function win_load()
{
var c10=document.getElementById("ci1");var ctx10=c10.getContext("2d");ctx10.fillStyle="#f00";ctx10.font="15pt Calibri";ctx10.fillText("Loading .",5,15);
var c10=document.getElementById("ci2");var ctx10=c10.getContext("2d");ctx10.fillStyle="#f00";ctx10.font="15pt Calibri";ctx10.fillText(" .",5,15);
var c10=document.getElementById("ci3");var ctx10=c10.getContext("2d");ctx10.fillStyle="#f00";ctx10.font="15pt Calibri";ctx10.fillText(" .",5,15);
}
</script>
</head>
<body>
<div id="d1">
<canvas id="ci1" class="cc1" width="100" height="100"></canvas>
<canvas id="ci2" class="cc2" width="100" height="100"></canvas>
<canvas id="ci3" class="cc3" width="100" height="100"></canvas>
</div>
</body>