website view libs/js/slideshow.js @ rev 882
Main index: prepa for release 4.0 RC1
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu Feb 23 01:09:37 2012 +0100 (2012-02-23) |
parents | |
children |
line source
2 window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);
4 var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
6 function so_init()
7 {
8 if(!d.getElementById || !d.createElement)return;
10 imgs = d.getElementById('slideshow').getElementsByTagName('img');
11 for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
12 imgs[0].style.display = 'block';
13 imgs[0].xOpacity = .99;
15 setTimeout(so_xfade,4000);
16 }
18 function so_xfade()
19 {
20 cOpacity = imgs[current].xOpacity;
21 nIndex = imgs[current+1]?current+1:0;
22 nOpacity = imgs[nIndex].xOpacity;
24 cOpacity-=.05;
25 nOpacity+=.05;
27 imgs[nIndex].style.display = 'block';
28 imgs[current].xOpacity = cOpacity;
29 imgs[nIndex].xOpacity = nOpacity;
31 setOpacity(imgs[current]);
32 setOpacity(imgs[nIndex]);
34 if(cOpacity<=0)
35 {
36 imgs[current].style.display = 'none';
37 current = nIndex;
38 setTimeout(so_xfade,4000);
39 }
40 else
41 {
42 setTimeout(so_xfade,60);
43 }
45 function setOpacity(obj)
46 {
47 if(obj.xOpacity>.99)
48 {
49 obj.xOpacity = .99;
50 return;
51 }
53 obj.style.opacity = obj.xOpacity;
54 obj.style.MozOpacity = obj.xOpacity;
55 obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
56 }
57 }