HTML Blitz






      This is a tutorial for a simple gallery slide. many web designers and developers are using a JQuery, javascript or any other scripts that gives their gallery look more fancy and beautiful.Well in this tutorial you dont need that scripts in html 5 the designers and developers can create their own gallery with their own style.

      First you need to have picture like this...
 file names must start in "p"+corresponding number+".jpg"



<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Blit</title>


<script>


var context;
var x=0;
var ind;
var offset;


var photos = new Array();
for( var i=1; i<15; i++){
var im = new Image();
im.src = "p"+i+".PNG";      ( edit this if you want "p" is the name of the picture plus its number)
photos.push(im);

}


function init() {
context = document.getElementById('canvas').getContext('2d');
setInterval(loop, 10);                   ( you can edit the "10" its the speed of the slide)
}

function lopp(){
x +=(slider.value - x) * 0.1;
ind = Math.floor(x/800);
offset = x % 800;
context.drawImage(photos[ind], offset, 0, 800-offset, 600, 0, 0, 800-offset, 600);
context.drawImage(photos[ind+1], 0, 0, 800, 600, 800-offset, 0, 800, 600);
}


</script>


</head>


<body onLoad="init()">


<canvas width="800" height="600" id="canvas"> </canvas>
<br/>


<input type="range" id="slider" style=" width:800px" min="0" max="10400" step="1"  value="0">


</body>
</html>

Now you after editing, you can have this output


and this


that's it! enjoy.. 

Penulis : Unknown ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel HTML Blitz ini dipublish oleh Unknown pada hari Wednesday, October 19. Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan HTML Blitz
 

0 Comments:

Post a Comment

Disqus

blog comments powered by Disqus
Powered by Blogger.

MGID News