JS简单的轮播的图片滚动实例
时间:2024-03-19 19:46:31
[javascript]
var forimg = function (foritem, hoverStop, defaultfor) {
var _foritem = foritem.constructor == jQuery ? foritem : $(foritem);
var imgarr = [
{ "z-index": 1, "width": 100, "height": 100, "left": 0, "top": "75px" },
{ "z-index": 2, "width": 200, "height": 200, "left": 50, "top": "25px" },
{ "z-index": 3, "width": 300, "height": 250, "left": 150, "top": "0" },
{ "z-index": 2, "width": 200, "height": 200, "left": 370, "top": "25px" },
{ "z-index": 1, "width": 100, "height": 100, "left": 520, "top": "75px" }
];
_foritem.each(function (i) {
var _this = $(this);
_this.css(imgarr[i] || imgarr[4]);
_this.find("img").css(imgarr[i] || imgarr[4]);
}); www.aspxhome.com
var _for = function (_i, data, nulldata, callback) {
$(foritem).each(function (i) {
var self = $(this);
setTimeout(function () {
self.css("z-index", (data[i + _i] || nulldata)["z-index"])
self.stop().animate(data[i + _i] || nulldata);
self.find("img").stop().animate(data[i + _i] || nulldata, function () {
callback.call(self, i);
});
});
});
};
var that = this;
var defaultforfun = function () {
if (!defaultfor) {
that.leftfor();
} else {
that.rightfor();
}
}
var forimgInterval = setInterval(defaultforfun, 1000);
if (hoverStop) {
_foritem.hover(function () {
clearInterval(forimgInterval);
}, function () {
forimgInterval = setInterval(defaultforfun, 1000);
});
}
this.leftfor = function () {
var nuldata = { "z-index": -1, "width": 100, "height": 100, "left": 520, "top": "75px" };
imgarr[0]["z-index"] = 1;
imgarr[0]["z-index"] = 2
imgarr[0]["z-index"] = 3
imgarr[0]["z-index"] = 2
imgarr[0]["z-index"] = 1
_for(-1, imgarr, nuldata, function (i) {
if (i == 0) {
this.closest("ul").append(this);
}
});
};
this.rightfor = function () {
var nuldata = { "z-index": -1, "width": 100, "height": 100, "left": 0, "top": "75px" };
imgarr[0]["z-index"] = 1;
imgarr[0]["z-index"] = 2
imgarr[0]["z-index"] = 4
imgarr[0]["z-index"] = 5
imgarr[0]["z-index"] = 2
_for(1, imgarr, nuldata, function (i) {
if (i == _foritem.length - 1) {
this.closest("ul").prepend(this);
this.css("z-index", "1");
}
});
};
this.stop = function () {
clearInterval(forimgInterval);
};
this.next = function () {
forimgInterval = setInterval(defaultforfun, 1000);
};
};
标签:轮播,图片,滚动
0
投稿
猜你喜欢
MySQL复制表结构和内容到另一张表中的SQL语句
2024-01-20 17:20:59
Python中的filter()函数的用法
2022-04-23 11:42:15
sql 分组查询问题
2024-01-21 05:50:00
Python读取环境变量的方法和自定义类分享
2022-11-13 23:47:08
基于mysql 默认排序规则的坑
2024-01-17 11:38:56
Python 调用 Outlook 发送邮件过程解析
2023-11-17 19:34:57
MySql中的常用参数查询
2024-01-18 06:00:30
Python 虚拟机集合set实现原理及源码解析
2023-11-20 11:36:13
微信小程序学习笔记之文件上传、下载操作图文详解
2023-09-07 21:13:21
python之import机制详解
2022-11-29 02:47:40
PHP开发实现微信退款功能示例
2023-06-30 09:10:25
Python机器学习库scikit-learn使用详解
2021-08-03 08:21:41
Linux安装MySQL5.6.24使用文字说明
2024-01-24 22:20:54
python获取指定网页上所有超链接的方法
2023-07-18 11:50:20
Go语言题解LeetCode1266访问所有点的最小时间示例
2023-08-29 08:10:39
Python使用Chrome插件实现爬虫过程图解
2023-08-01 02:02:29
SQL Server跨服务器操作数据库的图文方法(LinkedServer)
2024-01-16 20:05:50
python hmac模块验证客户端的合法性
2021-08-21 19:18:11
小程序中英文混合排序问题解决
2024-04-28 09:41:17
SQL开窗函数的具体实现详解
2024-01-26 12:16:37