300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > js实现有过渡渐变效果的图片轮播相册(兼容IE ff)【javascript】

js实现有过渡渐变效果的图片轮播相册(兼容IE ff)【javascript】

时间:2019-08-23 00:36:22

相关推荐

js实现有过渡渐变效果的图片轮播相册(兼容IE ff)【javascript】

web前端|js教程

js,渐变,图片轮播

web前端-js教程

本文实例介绍了js实现图片轮播相册,具有过渡渐变效果,分享给大家供大家参考,具体内容如下

快递代取网站源码,Ubuntu开机引导没了,tomcat要按两次停止,就诊记录爬虫,页游服务器php,seo怎么取名lzw

思路很简单,用2个属性保存当前图片和上一张图片,用2个定时器分别控制透明度和当前过渡的图片。

登录网页界面源码,ubuntu3dmax,爬虫抓取隐藏页面,php wsl,siguo_seolzw

#cnt{width:100%;height:80%;} .ctrl{text-align:center;border:1px solid gray;font-size:12px;cursor:pointer;} <!-- var curOpac = 0; var filterTimer; var isIE = /internet explorer/i.test(window.navigator.appName);function MyScroll(cnt, control){this.data = []; // 存放图片路径this.interval = 3000; // 过渡一次的间隔时间(过渡时间+图片显示时间)this.timer; // 定时器:控制当前显示的图片this.container = cnt;this.curFrame = 0;this.oldFrame = 0;this.controls = control; // 按钮集合Global = this;// 获取对象的指针this.run = function(){ this.timer = window.setInterval("Global.showFrame()", this.interval);}// 按钮的处理程序this.go = function(i){ curOpac = 0; // 透明度归0 this.curFrame = i; // 当前要过渡的图片 this.stop(); // 清空计时器 this.showFrame(); // 当前图片过渡 this.run(); // 循环播放}this.stop = function(){ window.clearInterval(this.timer); window.clearInterval(filterTimer);}this.showFrame = function(){ // 设置当前按钮样式 this.controls[this.oldFrame].style.backgroundColor = "white"; this.controls[this.curFrame].style.backgroundColor = "gray"; if(isIE) this.container.style.filter = "alpha(opacity=0)"; else this.container.style.cssText = "-moz-opacity:0"; this.container.innerHTML = this.data[this.curFrame]; filterTimer = window.setInterval("blend()", 100); this.oldFrame = this.curFrame; this.curFrame ++; if(this.curFrame == this.data.length){ this.curFrame = 0; } } } // 增加透明度 function blend(){curOpac+=10;if(isIE) Global.container.style.filter=alpha(opacity= + curOpac + );else Global.container.style.cssText = "-moz-opacity:" + curOpac/100.0;if(curOpac == 100){ curOpac = 0; window.clearInterval(filterTimer);} } //开始function startIt(){var imgArr = [];// 创建4个图片对象保存图片路径for(var i=0;i<4;i++){ imgArr[i] = new Image(); imgArr[i].src = "images/banner" + (i + 1) + ".jpg";}var controlArr = $("mainTb").getElementsByTagName("span");for(var i=0;i<controlArr.length;i++){ controlArr[i].tag = i; controlArr[i].onclick = function(){ myScroll.go(this.tag); }}var myScroll = new MyScroll($("cnt"), controlArr);myScroll.data.push("");myScroll.data.push("");myScroll.data.push("");myScroll.data.push("");myScroll.go(0); }window.onload = startIt; function $(id){ return document.getElementById(id);} //-->

php账号交易源码,ubuntu中r安装,泰坦版骷髅爬虫,php strrchr,seo学习小组lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。