一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

好看的js幻燈效果,圖片切換輪播代碼

 道理王 2011-11-19
<script type="text/javascript">
function e(p,ele) {return p.getElementsByTagName(ele)};
function el(id) {return document.getElementById(id)};
function t(o,e,f) {o.addEventListener?o.addEventListener(e,f,false):o.attachEvent('on'+e,f)};
var ss = {};
ss.slider = function() {
var arg, move = function() {};
move.prototype.init = function(opt) {
arg = this.set(opt);
var wrap = el(opt.gallery),
ctl = el(opt.control),
obj = this.obj = e(wrap,'ul')[0],
$this = this;
this.u = e(obj,'li');
this.cu = e(ctl,'li');
this.uW = this.u[0].offsetWidth;
this.uH = this.u[0].offsetHeight;
this.len = this.u.length;
this.old = this.cur = arg.index;
wrap.style.cssText = 'width:' + this.uW + 'px;' + 'height:' + this.uH + 'px;' + 'overflow: hidden;';
obj.style.cssText = 'height:' + this.uH + 'px;' + 'width:' + (arg.dir ? this.uW + 'px;' : this.len * this.uW + 'px;') + (arg.dir ? 'top:' + -1 * this.cur * this.uH + 'px;' : 'left:' + -1 * this.cur * this.uW + 'px;');
this.cu[this.cur].className = 'current';
this.event(arg.type);
setTimeout(function() {$this.auto()},arg.interval);
};
move.prototype.set = function(opt) {
org = {
gallery: 'gal-wrap',
control: "gal-panel",
dir: false,
index: 0,
speed: 16,
interval: 3000,
type: 'click'
};
for(var p in opt) {
org[p] = opt[p]
}
return org;
};
move.prototype.timeMgr = function() {
var $this = this;
this.m = setTimeout(function() {$this.auto(); $this.indexMgr()},arg.interval);
};
move.prototype.auto = function() {
var $this = this;
if(this.a != undefined) clearInterval(this.a);
this.a = setInterval(function() {$this.pos()},arg.speed);
};
// Downloads By http://down.
move.prototype.pos = function() {
var dir = arg.dir ? parseInt(this.obj.style.top) : parseInt(this.obj.style.left),
area = arg.dir ? this.uH : this.uW,
dis = (area * this.cur + dir) * .1,
step = dis >= 0 ? Math.ceil(dis) : Math.floor(dis);
arg.dir ? this.obj.style.top = dir - step + 'px' : this.obj.style.left = dir - step + 'px';
this.stop(dir,area);
};
move.prototype.stop = function(dir,area) {
if(Math.abs(dir) == area * this.cur) {
clearInterval(this.a);
this.cur == this.len - 1 ? this.cur = 0 : this.cur++;
this.timeMgr();
}
};
move.prototype.indexMgr = function() {
this.cu[this.cur].className = 'current';
if(this.old != this.cur) {
this.cu[this.old].className = '';
this.old = this.cur;
}
};
move.prototype.event = function(e) {
for(var i = 0; i < this.cu.length; i++) {
var $this = this;
t(this.cu[i],e,num(i,$this));
}
function num(n,$this) {
return function() {
clearInterval($this.a);
clearTimeout($this.m);
$this.cu[n].className = 'current';
if($this.old != n) {
$this.cu[$this.old].className = '';
$this.old = $this.cur = n;
}
$this.c = 0;
$this.auto();
}
}
};
return move;
}();
</script>
<style type="text/css">
* {margin: 0; padding: 0;}
body {padding: 0 0 50px 50px;}
#gal-wrap {
position: relative;
}
#gallery {
position: absolute;
}
#gallery li {
list-style: none;
float: left;
width: 450px;
height: 350px;
}
#gallery p {
text-align: center;
color: #cdcdcd;
}
#gal-panel {
height: 100%;
overflow: hidden;
}
#gal-panel li {
float: left;
margin-right: 6px;
list-style: none;
cursor: pointer;
}
#gal-panel li.current {
font-weight: bold;
color: red;
}
</style>
</head>
<body>
<div id="gal-wrap">
<ul id="gallery">
<li><p><img src="http://www./uploads/common/images/p7.jpg" /></p></li>
<li><p><img src="http://www./uploads/common/images/p5.jpg" /></p></li>
<li><p><img src="http://www./uploads/common/images/p3.jpg" /></p></li>
<li><p><img src="http://www./uploads/common/images/p4.jpg" /></p></li>
</ul>
</div>
<div id="gal-panel">
<ul id="gallery-panel">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<script type="text/javascript">
var tt = new ss.slider();
tt.init({
gallery: 'gal-wrap',
control: "gal-panel",
dir: false,
index: 0,
speed: 20,
interval: 1000,
type: 'mouseover'
});
</script>
</body>
</html>

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    国产午夜福利片在线观看| 女同伦理国产精品久久久| 欧美一区日韩一区日韩一区| 欧美日韩精品人妻二区三区| 国产精品亚洲综合天堂夜夜| 亚洲第一区二区三区女厕偷拍| 在线观看视频国产你懂的| 国产成人精品一区二区三区| 亚洲中文字幕人妻系列| 国产偷拍盗摄一区二区| 国产精品久久三级精品| 国产亚洲视频香蕉一区| 精品国模一区二区三区欧美| 毛片在线观看免费日韩| 蜜桃传媒视频麻豆第一区| 亚洲精品成人午夜久久| 熟女乱一区二区三区丝袜| 日韩国产亚洲欧美另类| 日韩三极片在线免费播放| 久久香蕉综合网精品视频| 男生和女生哪个更好色| 欧美丝袜诱惑一区二区| 亚洲欧美日本国产有色| 搡老妇女老熟女一区二区| 国产成人精品午夜福利| 伊人网免费在线观看高清版| 日韩精品在线观看完整版| 五月天丁香婷婷狠狠爱| 丁香七月啪啪激情综合| 日韩高清一区二区三区四区| 午夜福利黄片免费观看| 99少妇偷拍视频在线| 亚洲精品国产美女久久久99| 黄片免费观看一区二区| 国产性情片一区二区三区| 色哟哟精品一区二区三区| 日韩精品少妇人妻一区二区| 亚洲夫妻性生活免费视频| 中文字幕精品少妇人妻| 亚洲三级视频在线观看免费| 久热99中文字幕视频在线|