凹丫丫网络社区's Archiver

Amm 发表于 2008-5-16 13:01

炫!旋转灯笼式图片展示

<P>网页图片特效 - 炫!旋转灯笼式图片展示 <A href="http://www.butong.net/img/051126/demonstration.htm">http://www.butong.net/img/051126/demonstration.htm</A></P>
<P>&nbsp;</P>
<P>把如下代码复制到&lt;head&gt;与&lt;/head&gt;之间</P>
<P>&lt;script type='text/javascript'&gt;<BR>//more javascript from <A href="http://www.smallrain.net">http://www.smallrain.net</A><BR>function carousel(params){<BR>&nbsp; if(!(params.width&gt;0 &amp;&amp; isFinite(params.width)))params.width=100;<BR>&nbsp; if(!(params.height&gt;0 &amp;&amp; isFinite(params.height)))params.height=100;<BR>&nbsp; if(!(params.sides&gt;2 &amp;&amp; isFinite(params.sides)))params.sides=4;<BR>&nbsp; if(!(params.steps&gt;0 &amp;&amp; params.steps&lt;100 &amp;&amp; isFinite(params.steps)))params.steps=20;<BR>&nbsp; if(!(params.speed&gt;0 &amp;&amp; isFinite(params.speed)))params.speed=8;<BR>&nbsp; if(!(params.image_border_width&gt;=0 &amp;&amp; isFinite(params.image_border_width)))params.image_border_width=0;<BR>&nbsp; if(isFinite(params.id)||!params.id)params.id='bad_id_given_'+Math.random();<BR>&nbsp; <BR>&nbsp; document.write("&lt;div style='position:relative;overflow:hidden;' id='"+params.id.replace(/[\r\n\t ]+/g,'_')+"'&gt;&lt;/div&gt;");<BR>&nbsp; var cdiv=document.getElementById(params.id.replace(/[\r\n\t ]+/g,'_'))<BR>&nbsp; cdiv.style.width=params.width+'px';<BR>&nbsp; cdiv.style.height=params.height+'px';<BR>&nbsp; cdiv.style.border=params.border;<BR>&nbsp; cdiv.style.position='relative';<BR>&nbsp; cdiv.style.overflow='hidden';<BR>&nbsp; cdiv.title=params.id;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; var counter=0,spinning=true,interval=Math.floor(60000/params.sides/params.steps/params.speed)-5;<BR>&nbsp; interval=isNaN(interval)?200:interval;<BR>&nbsp; var img_position=[],images=[],img_dimension=[];<BR>&nbsp; var img_index=params.images.length+1,img_index_cap=2*params.images.length;<BR>&nbsp; var faces=Math.ceil(params.sides/2), dimension, direction;</P>
<P>&nbsp; function init(){<BR>&nbsp;&nbsp;&nbsp; if(params.direction=="left" || params.direction=="right"){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direction=params.direction;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dimension="width";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else if(params.direction=="top" || params.direction=="bottom"){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direction=params.direction;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dimension="height";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direction="left";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dimension="width";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; cdiv.style[dimension]=params[dimension]/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)+'px';<BR>&nbsp;&nbsp;&nbsp; var img=new Image();<BR>&nbsp;&nbsp;&nbsp; img.style.position='absolute';<BR>&nbsp;&nbsp;&nbsp; img.style[direction]='10000px';<BR>&nbsp;&nbsp;&nbsp; img.style.width=params.width-2*params.image_border_width+'px';<BR>&nbsp;&nbsp;&nbsp; img.style.height=params.height-2*params.image_border_width+'px';<BR>&nbsp;&nbsp;&nbsp; img.style.border=(params.image_border_width||0)+'px solid '+params.image_border_color;<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp; for(var i=0;i&lt;params.images.length;i++){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i]=img.cloneNode(true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i].src=params.images[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(params.links &amp;&amp; params.links[i] &amp;&amp; params.links[i]!=''){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i].onclick=new Function("window.location='"+params.links[i]+"'");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i].style.cursor=document.all?'hand':'pointer';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(params.titles &amp;&amp; params.titles[i] &amp;&amp; params.titles[i]!='')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i].title=params.titles[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i+params.images.length]=images[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(params.images.length==faces)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[i+2*params.images.length]=images[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cdiv.appendChild(images[i]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp; var face_size=params.size_mode=='image'?params[dimension]:params[dimension]*Math.sin(Math.PI/params.sides);<BR>&nbsp;&nbsp;&nbsp; var face_offset=params[dimension]*Math.cos(Math.PI/params.sides)/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)/2-.5;<BR>&nbsp;&nbsp;&nbsp; var pi_piece=2*Math.PI/params.steps/params.sides;<BR>&nbsp;&nbsp;&nbsp; for(i=0;i&lt;=params.steps*faces;i++){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; img_dimension[i]=face_size*Math.sin(pi_piece*i);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; img_position[i]=(i&lt;params.steps*params.sides/2)?Math.floor(params[dimension]/2/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)-face_offset*Math.cos(pi_piece*i)-img_dimension[i]/2)+'px':'10000px';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; img_dimension[i]=img_dimension[i]-2*params.image_border_width&gt;1?Math.ceil(img_dimension[i])-2*params.image_border_width+'px':'1px';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; init();</P>
<P>&nbsp; cdiv.rotate = function(){<BR>&nbsp;&nbsp;&nbsp; setTimeout('document.getElementById("'+cdiv.id+'").rotate()',interval);<BR>&nbsp;&nbsp;&nbsp; if(!spinning) return;<BR>&nbsp;&nbsp;&nbsp; if(++counter&gt;=params.steps){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(++img_index&gt;=img_index_cap)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; img_index=params.images.length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; images[img_index-faces].style[direction]='20000px';<BR>&nbsp;&nbsp;&nbsp; for(var i=faces-1;i&gt;=0;i--){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[img_index-i].style[direction]=img_position[counter+i*params.steps];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images[img_index-i].style[dimension]=img_dimension[counter+i*params.steps];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; cdiv.onmouseover=function(){<BR>&nbsp;&nbsp;&nbsp; spinning=false;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; cdiv.onmouseout=function(){<BR>&nbsp;&nbsp;&nbsp; spinning=true;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; setTimeout('document.getElementById("'+cdiv.id+'").rotate()',200);<BR>&nbsp; }<BR>&lt;/script&gt;</P>
<P>把如下代码复制到&lt;body&gt;与&lt;/body&gt;之间</P>
<P>&lt;h3&gt;&lt;font color="#FFFFFF"&gt;水平方向滚动&lt;/font&gt;&lt;/h3&gt;<BR>&lt;font color="#FFFFFF"&gt;<BR>&lt;script type='text/javascript'&gt;<BR>carousel({id:'Amazon Books', //Enter arbitrary but unique ID of this slideshow instance<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border:'',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size_mode:'image', //Enter "carousel" or "image". Affects the width and height parameters below.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width:107, //Enter width of image or entire carousel, depending on above value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height:140, //Enter height of image or entire carousel, depending on above value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sides:6, //# of sides of the carousel. What's shown = sides/2. Even integer with sides/2&lt; total images is best<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; steps:23, //# of animation steps. More = smoother, but more CPU intensive<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; speed:5, //Speed of slideshow. Larger = faster.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direction:'left', //Direction of slideshow. Enter "top", "bottom", "left", or "right"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images:['photo1.jpg',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'photo2.jpg',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'photo3.jpg',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'photo4.jpg'],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; links: ['http://www.butong.net',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'http://www.butong.net',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'http://www.butong.net/background/index.htm',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'http://www.butong.net/navigation/index.htm'],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; titles:['javascript特效',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'网页特效库',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'背景特效',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'导航特效'],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; image_border_width:1,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; image_border_color:'blue'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<BR>&lt;/script&gt;</P>
<P><BR>&lt;/font&gt;</P>
<P><BR>&lt;h3&gt;&lt;font color="#FFFFFF"&gt;竖直方向滚动&lt;/font&gt;&lt;/h3&gt;<BR>&lt;script type='text/javascript'&gt;<BR>carousel({id:'carousel_1', //Enter arbitrary but unique ID of this slideshow instance<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border:'',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size_mode:'image', //Enter "carousel" or "image". Affects the width and height parameters below.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width:107, //Enter width of image or entire carousel, depending on above value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height:140, //Enter height of image or entire carousel, depending on above value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sides:8, //# of sides of the carousel. What's shown = sides/2. Even integer with sides/2&lt; total images is best<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; steps:8, //# of animation steps. More = smoother, but more CPU intensive<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; speed:7, //Speed of slideshow. Larger = faster.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direction:'top', //Direction of slideshow. Enter "top", "bottom", "left", or "right"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; images:['photo1.jpg',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'photo2.jpg',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'photo3.jpg',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'photo4.jpg'],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; links: [],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; titles:[],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; image_border_width:1,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; image_border_color:'black'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<BR>&lt;/script&gt;</P>

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.