日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

仿淘宝首页图片切换

發(fā)布時間:2023/12/13 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 仿淘宝首页图片切换 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

?

?

資料來源:http://www.cnblogs.com/cloudgamer/archive/2008/07/06/SlideTrans.html?page=2#pagedcomment

?

效果展示:

測試環(huán)境:IE8 (待續(xù))

?

程序代碼:

?

代碼 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>仿淘寶首頁圖片切換</title>
<style type="text/css">
.container ul, .container li
{
list-style
: none;
margin
: 0;
padding
: 0;
}
.container, .container img
{
width
: 470px;
height
: 150px;
}
.load
{
/*此處background-position:50% 50% 似乎不作用(限blog頁面)*/
background
: url(http://img02.taobaocdn.com/tps/i2/T16WJqXaXeXXXXXXXX-32-32.gif) #ebf5fa no-repeat 225px 55px;
width
: 470px;
height
: 150px;
overflow
: hidden;
}
.container img
{
border
: 0;
vertical-align
: top;
}
.num
{
position
: absolute;
right
: 5px;
bottom
: 5px;
font
: 12px/1.5 tahoma, arial;
height
: 18px;
}
.num li
{
float
: left;
color
: #d94b01;
text-align
: center;
line-height
: 16px;
width
: 16px;
height
: 16px;
font-family
: Arial;
font-size
: 11px;
cursor
: pointer;
margin-left
: 3px;
border
: 1px solid #f47500;
background-color
: #fcf2cf;
}
.num li.on
{
line-height
: 18px;
width
: 18px;
height
: 18px;
font-size
: 14px;
margin-top
: -2px;
background-color
: #ff9415;
font-weight
: bold;
color
: #FFF;
}
</style>
<script type="text/javascript">

var $$ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};

var Extend = function (destination, source) {
for (var property in source) {
destination[property]
= source[property];
}
return destination;
}

var CurrentStyle = function (element) {
return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}

var Bind = function (object, fun) {
var args = Array.prototype.slice.call(arguments).slice(2);
return function () {
return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
}
}

var forEach = function (array, callback, thisObject) {
if (array.forEach) {
array.forEach(callback, thisObject);
}
else {
for (var i = 0, len = array.length; i < len; i++) { callback.call(thisObject, array[i], i, array); }
}
}

var Tween = {
Quart: {
easeOut:
function (t, b, c, d) {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
}
},
Back: {
easeOut:
function (t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
}
},
Bounce: {
easeOut:
function (t, b, c, d) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) + b;
}
else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
}
else if (t < (2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
}
else {
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
}
}
}
}


//容器對象,滑動對象,切換數(shù)量
var SlideTrans = function (container, slider, count, options) {
this._slider = $$(slider);
this._container = $$(container); //容器對象
this._timer = null; //定時器
this._count = Math.abs(count); //切換數(shù)量
this._target = 0; //目標值
this._t = this._b = this._c = 0; //tween參數(shù)

this.Index = 0; //當前索引

this.SetOptions(options);

this.Auto = !!this.options.Auto;
this.Duration = Math.abs(this.options.Duration);
this.Time = Math.abs(this.options.Time);
this.Pause = Math.abs(this.options.Pause);
this.Tween = this.options.Tween;
this.onStart = this.options.onStart;
this.onFinish = this.options.onFinish;

var bVertical = !!this.options.Vertical;
this._css = bVertical ? "top" : "left"; //方向

//樣式設置
var p = CurrentStyle(this._container).position;
p
== "relative" || p == "absolute" || (this._container.style.position = "relative");
this._container.style.overflow = "hidden";
this._slider.style.position = "absolute";

this.Change = this.options.Change ? this.options.Change :this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
};
SlideTrans.prototype
= {
//設置默認屬性
SetOptions: function (options) {
this.options = {//默認值
Vertical: true, //是否垂直方向(方向不能改)
Auto: true, //是否自動
Change: 0, //改變量
Duration: 30, //滑動持續(xù)時間
Time: 10, //滑動延時
Pause: 3000, //停頓時間(Auto為true時有效)
onStart: function () { }, //開始轉換時執(zhí)行
onFinish: function () { }, //完成轉換時執(zhí)行
Tween: Tween.Quart.easeOut//tween算子
};
Extend(
this.options, options || {});
},
//開始切換
Run: function (index) {
//修正index
index == undefined && (index = this.Index);
index
< 0 && (index = this._count - 1) || index >= this._count && (index = 0);
//設置參數(shù)
this._target = -Math.abs(this.Change) * (this.Index = index);
this._t = 0;
this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
this._c = this._target - this._b;

this.onStart();
this.Move();
},
//移動
Move: function () {
clearTimeout(
this._timer);
//未到達目標繼續(xù)移動否則進行下一次滑動
if (this._c && this._t < this.Duration) {
this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
this._timer = setTimeout(Bind(this, this.Move), this.Time);
}
else {
this.MoveTo(this._target);
this.Auto && (this._timer = setTimeout(Bind(this, this.Next), this.Pause));
}
},
//移動到
MoveTo: function (i) {
this._slider.style[this._css] = i + "px";
},
//下一個
Next: function () {
this.Run(++this.Index);
},
//上一個
Previous: function () {
this.Run(--this.Index);
},
//停止
Stop: function () {
clearTimeout(
this._timer); this.MoveTo(this._target);
}
};
</script>
</head>
<body>
<div class="container load" id="idContainer">
<ul id="idSlider">
<li><a href="#">
<img src="http://img08.taobaocdn.com/tps/i8/T1_mxCXhBGXXXXXXXX-470-150.jpg" alt="" />
</a></li>
<li><a href="#">
<img src="http://img.alimama.cn/bcrm/adboard/picture/2010-06-10/100610131313970.gif" alt="" />
</a></li>
<li><a href="#">
<img src="http://img.alimama.cn/bcrm/adboard/picture/2010-06-11/100611120247446.jpg" alt="" />
</a></li>
<li><a href="#">
<img src="http://img.alimama.cn/bcrm/adboard/picture/2010-06-11/100611112912364.jpg" alt="" />
</a></li>
<li><a href="#">
<img src="http://img01.taobaocdn.com/tps/i1/T1KpNDXmBaXXXXXXXX-470-150.gif" alt="" />
</a></li>
</ul>
<ul class="num" id="idNum">
</ul>
</div>
<script type="text/javascript">

var nums = [], timer, n = $$("idSlider").getElementsByTagName("li").length,

st
= new SlideTrans("idContainer", "idSlider", n, {
onStart:
function () {//設置按鈕樣式
forEach(nums, function (o, i) {
o.className
= st.Index == i ? "on" : "";
})
}
});

for (var i = 1; i <= n; AddNum(i++)) {
};
function AddNum(i) {
var num = $$("idNum").appendChild(document.createElement("li"));
num.innerHTML
= i--;
num.onmouseover
= function () {
timer
= setTimeout(function () { num.className = "on"; st.Auto = false; st.Run(i); }, 200);
}
num.onmouseout
= function () { clearTimeout(timer); num.className = ""; st.Auto = true; st.Run(); }
nums[i]
= num;
}
st.Run();
</script>
</body>
</html>

?

源代碼下載

轉載于:https://www.cnblogs.com/uedt/archive/2010/06/12/1757135.html

總結

以上是生活随笔為你收集整理的仿淘宝首页图片切换的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 大陆极品少妇内射aaaaa | 久久午夜网| 午夜大片 | 中文在线字幕 | 超碰97av| www日韩视频 | 亚洲熟妇av乱码在线观看 | 国产高清自拍av | 六月色丁香 | 人妻熟女一区二区aⅴ水 | 成人精品久久久 | 麻豆国产原创 | 欧美性天堂 | 国产情侣小视频 | 日韩无码精品一区二区三区 | 日韩精品一区二区三区在线视频 | 午夜久久久久 | 综合精品视频 | 国产精品麻豆欧美日韩ww | 亚洲无线观看 | 青青草免费在线视频 | 五月婷婷久 | 那个网站可以看毛片 | 最近的中文字幕在线看视频 | 国产视频1区2区3区 国产欧美一区二区精品性色99 | 2020亚洲天堂 | 黑人一级| 国产高清片 | 男女一级特黄 | 欧美日韩中文在线观看 | 国产成人免费 | 久久久久久久久国产 | 玉蒲团在线 | 黄色大片免费在线观看 | 国产福利一区二区三区视频 | 精品三级视频 | 麻豆成人久久精品一区二区三区 | 黄色免费成人 | 亚洲精品女 | 中文视频一区二区 | 国产精品五月天 | 天天干天天插天天射 | 青青草超碰 | 久久精品视频网 | 丁香午夜 | 国产精品久久久久久 | 国产超碰人人模人人爽人人添 | 成人免费xxxxx在线观看 | 午夜精品福利在线观看 | 精品久久ai | 激情国产在线 | 激情噜噜| 91嫩草欧美久久久九九九 | av一区二区三区在线 | 女同性恋毛片 | 国产精品成人一区二区三区 | 亚洲乱熟女一区二区三区小说 | 一本色道久久综合亚洲二区三区 | 久久精品免费一区二区 | 伊人久久色 | 欧洲一区在线 | 手机在线视频一区 | 主播av在线 | 日本黄色动态图 | 在线观看黄色免费网站 | 色婷婷狠狠干 | 国产色拍 | 日本888xxxx| 国产精品毛片在线 | 黄色工厂这里只有精品 | 黄瓜视频91 | 三级网站免费 | 明星双性精跪趴灌满h | 亚洲av男人的天堂在线观看 | 日本久久影视 | 免费观看成年人网站 | 得得的爱在线视频 | 欧洲精品无码一区二区 | 国产五十路 | 国产精品国产三级国产在线观看 | h部分肌肉警猛淫文 | 国产一区二区三区久久 | 日韩免费高清一区二区 | 久久久久99精品成人片我成大片 | 午夜小视频在线播放 | 亚洲一区 在线播放 | 日本在线有码 | 欧美一区二区三区四区在线观看 | 国产成人a人亚洲精品无码 在线aa | 国产福利91精品一区二区三区 | 久久性片 | 黑人操亚洲人 | 精品少妇人妻av免费久久久 | 日本黄色大片免费看 | 成人三级黄色 | www,色| 日韩人妻精品一区二区三区 | 九九综合视频 | 黑人一区二区 |