分享
 
 
 

图像转变过程中添加水波纹效果[网页特效]

王朝html/css/js·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

<!--把下列代码放到HEAD区域内-->

<head>

<title>连续环绕滚动图片</title>

<script type='text/javascript'>

function carousel(params){

if(!(params.width>0 && isFinite(params.width)))params.width=100;

if(!(params.height>0 && isFinite(params.height)))params.height=100;

if(!(params.sides>2 && isFinite(params.sides)))params.sides=4;

if(!(params.steps>0 && params.steps<100 && isFinite(params.steps)))params.steps=20;

if(!(params.speed>0 && isFinite(params.speed)))params.speed=8;

if(!(params.image_border_width>=0 && isFinite(params.image_border_width)))params.image_border_width=0;

if(isFinite(params.id)||!params.id)params.id='bad_id_given_'+Math.random();

document.write("<div style='position:relative;overflow:hidden;' id='"+params.id.replace(/[\r\n\t ]+/g,'_')+"'></div>");

var cdiv=document.getElementById(params.id.replace(/[\r\n\t ]+/g,'_'))

cdiv.style.width=params.width+'px';

cdiv.style.height=params.height+'px';

cdiv.style.border=params.border;

cdiv.style.position='relative';

cdiv.style.overflow='hidden';

cdiv.title=params.id;

var counter=0,spinning=true,interval=Math.floor(60000/params.sides/params.steps/params.speed)-5;

interval=isNaN(interval)?200:interval;

var img_position=[],images=[],img_dimension=[];

var img_index=params.images.length+1,img_index_cap=2*params.images.length;

var faces=Math.ceil(params.sides/2), dimension, direction;

function init(){

if(params.direction=="left" || params.direction=="right"){

direction=params.direction;

dimension="width";

}

else if(params.direction=="top" || params.direction=="bottom"){

direction=params.direction;

dimension="height";

}

else {

direction="left";

dimension="width";

}

cdiv.style[dimension]=params[dimension]/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)+'px';

var img=new Image();

img.style.position='absolute';

img.style[direction]='10000px';

img.style.width=params.width-2*params.image_border_width+'px';

img.style.height=params.height-2*params.image_border_width+'px';

img.style.border=(params.image_border_width||0)+'px solid '+params.image_border_color;

//more javascript from http://www.knowsky.com

for(var i=0;i<params.images.length;i++){

images[i]=img.cloneNode(true);

images[i].src=params.images[i];

if(params.links && params.links[i] && params.links[i]!=''){

images[i].onclick=new Function("window.location='"+params.links[i]+"'");

images[i].style.cursor=document.all?'hand':'pointer';

}

if(params.titles && params.titles[i] && params.titles[i]!='')

images[i].title=params.titles[i];

images[i+params.images.length]=images[i];

if(params.images.length==faces)

images[i+2*params.images.length]=images[i];

cdiv.appendChild(images[i]);

}

var face_size=params.size_mode=='image'?params[dimension]:params[dimension]*Math.sin(Math.PI/params.sides);

var face_offset=params[dimension]*Math.cos(Math.PI/params.sides)/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)/2-.5;

var pi_piece=2*Math.PI/params.steps/params.sides;

for(i=0;i<=params.steps*faces;i++){

img_dimension[i]=face_size*Math.sin(pi_piece*i);

img_position[i]=(i<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';

img_dimension[i]=img_dimension[i]-2*params.image_border_width>1?Math.ceil(img_dimension[i])-2*params.image_border_width+'px':'1px';

}

}

init();

cdiv.rotate = function(){

setTimeout('document.getElementById("'+cdiv.id+'").rotate()',interval);

if(!spinning) return;

if(++counter>=params.steps){

counter=0;

if(++img_index>=img_index_cap)

img_index=params.images.length;

}

images[img_index-faces].style[direction]='20000px';

for(var i=faces-1;i>=0;i--){

images[img_index-i].style[direction]=img_position[counter+i*params.steps];

images[img_index-i].style[dimension]=img_dimension[counter+i*params.steps];

}

}

cdiv.onmouseover=function(){

spinning=false;

}

cdiv.onmouseout=function(){

spinning=true;

}

setTimeout('document.getElementById("'+cdiv.id+'").rotate()',200);

}

</script>

</head>

<!--把下列代码放到body区域内-->

<body>

<h3>水平方向滚动</h3>

<script type='text/javascript'>

carousel({id:'Amazon Books', //Enter arbitrary but unique ID of this slideshow instance

border:'',

size_mode:'image', //Enter "carousel" or "image". Affects the width and height parameters below.

width:107, //Enter width of image or entire carousel, depending on above value

height:140, //Enter height of image or entire carousel, depending on above value

sides:6, //# of sides of the carousel. What's shown = sides/2. Even integer with sides/2< total images is best

steps:23, //# of animation steps. More = smoother, but more CPU intensive

speed:5, //Speed of slideshow. Larger = faster.

direction:'left', //Direction of slideshow. Enter "top", "bottom", "left", or "right"

images:['http://www.knowsky.com/img/200406301.jpg',

'http://www.knowsky.com/img/200406302.jpg',

'http://www.knowsky.com/img/200406303.jpg',

'http://www.knowsky.com/img/200406304.jpg'],

links: ['http://www.knowsky.com/',

'http://www.knowsky.com/',

'http://www.knowsky.com/',

'http://www.knowsky.com/'],

titles:['javascript特效',

'网络学院',

'网站联盟',

'插件下载'],

image_border_width:1,

image_border_color:'blue'

});

</script>

<h3>竖直方向滚动</h3>

<script type='text/javascript'>

carousel({id:'carousel_1', //Enter arbitrary but unique ID of this slideshow instance

border:'',

size_mode:'image', //Enter "carousel" or "image". Affects the width and height parameters below.

width:107, //Enter width of image or entire carousel, depending on above value

height:140, //Enter height of image or entire carousel, depending on above value

sides:8, //# of sides of the carousel. What's shown = sides/2. Even integer with sides/2< total images is best

steps:8, //# of animation steps. More = smoother, but more CPU intensive

speed:7, //Speed of slideshow. Larger = faster.

direction:'top', //Direction of slideshow. Enter "top", "bottom", "left", or "right"

images:['http://www.knowsky.com/img/200406301.jpg',

'http://www.knowsky.com/img/200406302.jpg',

'http://www.knowsky.com/img/200406303.jpg',

'http://www.knowsky.com/img/200406304.jpg'],

links: [],

titles:[],

image_border_width:1,

image_border_color:'black'

});

</script>

</body>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有