插件Home:http://www.gmarwaha.com/jquery/jcarousellite/index.php
很棒的图片滚动插件,加入国人常用的习惯:鼠标悬停的效果。
html结构要求:
<div id="handler">
<ul>
<li><img /></li>
……
</ul>
</div>
div,ul都会自动加入合适的css,而且是相对定位。基本不需要额外css控制,当然在js生效前,会乱,如果网速慢的话。
有必要对div加额外的margin等,控制其居中或怎样。div的left属性为0,是插件自动设置的,所以不要通过这个去控制位置了。
(function($) { // Compliant with jquery.noConflict()
$.fn.jCarouselLite = function(o) {
o = $.extend({
btnPrev: null,
btnNext: null,
btnGo: null,
mouseWheel: false,
auto: null,
speed: 200,
easing: null,
vertical: false,
circular: true,
visible: 3,
start: 0,
scroll: 1,
beforeStart: null,
afterEnd: null
}, o || {});
return this.each(function() { // Returns the element collection. Chainable.
var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
if(tl == 0) {
return false;
}
if(o.circular) {
ul.prepend(tLi.slice(tl-v-1+1).clone())
.append(tLi.slice(0,v).clone());
o.start += v;
}
var li = $("li", ul), itemLength = li.size(), curr = o.start;
div.css("visibility", "visible");
li.css({overflow: "hidden", 'float': o.vertical ? "none" : "left"});
ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});
var liSize = o.vertical ? height(li) : width(li); // Full li size(incl margin)-Used for animation
var ulSize = liSize * itemLength; // size of full ul(total length, not just for the visible items)
var divSize = liSize * v; // size of entire div(total length for just the visible items)
li.css({width: li.width(), height: li.height()});
ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
div.css(sizeCss, divSize+"px"); // Width of the DIV. length of visible images
if(o.btnPrev)
$(o.btnPrev).click(function() {
return go(curr-o.scroll);
});
if(o.btnNext)
$(o.btnNext).click(function() {
return go(curr+o.scroll);
});
if(o.btnGo)
$.each(o.btnGo, function(i, val) {
$(val).click(function() {
return go(o.circular ? o.visible+i : i);
});
});
if(o.mouseWheel && div.mousewheel)
div.mousewheel(function(e, d) {
return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
});
var jcarouselliteAutoId;
if(o.auto) {
jcarouselliteAutoId = setInterval(function() {
go(curr+o.scroll);
}, o.auto+o.speed);
/* 2009年7月30日 添加鼠标浮动停止滚动 */
ul.hover(function(){
clearInterval(jcarouselliteAutoId);
},function(){
jcarouselliteAutoId = setInterval(function() {
go(curr+o.scroll);
}, o.auto+o.speed);
});
};
function vis() {
return li.slice(curr).slice(0,v);
};
function go(to) {
if(tl <= 3) {
return false;
}
if(!running) {
if(o.beforeStart)
o.beforeStart.call(this, vis());
if(o.circular) { // If circular we are in first or last, then goto the other end
if(to<=o.start-v-1) { // If first, then goto last
ul.css(animCss, -((itemLength-(v*2))*liSize)+"px");
// If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll;
} else if(to>=itemLength-v+1) { // If last, then goto first
ul.css(animCss, -( (v) * liSize ) + "px" );
// If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
} else curr = to;
} else { // If non-circular and to points to first or last, we just return.
if(to<0 || to>itemLength-v) return;
else curr = to;
} // If neither overrides it, the curr will still be "to" and we can proceed.
running = true;
ul.animate(
animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
function() {
if(o.afterEnd)
o.afterEnd.call(this, vis());
running = false;
}
);
// Disable buttons when the carousel reaches the last/first, and enable when not
if(!o.circular) {
$(o.btnPrev + "," + o.btnNext).removeClass("disabled");
$( (curr-o.scroll<0 && o.btnPrev)
||
(curr+o.scroll > itemLength-v && o.btnNext)
||
[]
).addClass("disabled");
}
}
return false;
};
});
};
function css(el, prop) {
return parseInt($.css(el[0], prop)) || 0;
};
function width(el) {
return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
};
function height(el) {
return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
};
})(jQuery);
分享到:
相关推荐
codemirror版本:https://codemirror.net/5/doc/releases.html
外国电影演员识别系统源码分享
mf3010 打印扫描一体机驱动管理软件。
2024免费毕业设计成品,包括源码+数据库+往届论文资料 启动教程:https://www.bilibili.com/video/BV11ktveuE2d 讲解视频:https://www.bilibili.com/video/BV1YfkHYwEME 二次开发教程:https://www.bilibili.com/video/BV1Cw2rY1ErC
chrome-headless-shell-linux64-135.0.7004.0 (Canary).zip
DeepSeek大模型介绍与展望.pptx
英特尔的公版原理图和PCB,cadence版本
《单容水箱液位精准调控:模糊控制策略的深度研究与复现》,单容水箱液位随动系统的模糊控制研究 模糊控制lunwen复现 期刊:化工与自动化仪表(2021年) 图1为结构图,图9为原文结构图, 版本不一样,器件略有调整 图7为结果图,图8为原文结果图 ,单容水箱液位;模糊控制;研究;论文复现;期刊;化工与自动化仪表;结构图;结果图;版本差异;器件调整,"模糊控制研究在单容水箱液位随动系统中的应用与复现"
一个windows上使用的搜索小工具
内容: 这份数据集包含了来自国际大洋发现计划(IODP)第342航次站点U1405、U1406、U1407、U1409和U1410的浮游有孔虫碳酸盐团簇同位素、稳定氧和碳同位素,以及沉积物中的GDGT(甘油二烷基甘油四醚)和烯酮数据。这些站点位于北大西洋的新foundland脊(U1407、U1409和U1410)和J-异常脊(U1405和U1406),用于创建覆盖整个新生代的几乎连续但低分辨率(约每92万年一个样本)的数据拼接,并重建了碳酸盐团簇同位素、TEX86和UK'37海表温度。每个样本包含20立方厘米的沉积物,覆盖2厘米的核心深度区间。年龄模型主要基于详细的船上生物-磁性地层学研究(Norris等,2014)。然而,在40.8 Ma至44.8 Ma时间段内,使用了Cappelli等人(2019)更新的U1410站点年龄模型,通过与U1408站点的年龄模型对比来确定。 访问此数据集,请点击这里:"" ()。
厨房用品分割系统源码&数据集分享
.
监控鞋类物品检测系统源码分享
2024免费毕业设计成品,包括源码+数据库+往届论文资料 启动教程:https://www.bilibili.com/video/BV11ktveuE2d 讲解视频:https://www.bilibili.com/video/BV1YfkHYwEME 二次开发教程:https://www.bilibili.com/video/BV1Cw2rY1ErC
曲线图异常波形检测系统源码分享
内容概要:本文介绍了动车组车号自动识别的现状及其存在的问题,提出了基于图像识别技术的新方法。文中详述了传统人工识别与RFID识别方法的不足,重点阐述了一种新的图像识别系统的设计与实施方案,该系统能够实现在多种恶劣环境下高效精确地获取动车组车号,并通过实际案例展示了这套系统的优势以及其在铁路行业的广阔应用前景。 适用人群:从事铁路运输管理、轨道交通系统开发维护的技术人员,尤其是负责动车组调度、监控及维修工作的相关人员。 使用场景及目标:①用于替代现有人工记录与RFID标签方式,提升动车组车号识别精度与效率;②适用于各种天气状况下的户外作业场景;③旨在构建更加智能化、信息化程度更高的铁路运输体系,助力智慧动车段建设。 其他说明:文中还包括具体的实验对比和技术细节分析,如不同的开机触发装置选择、图像采集设备参数设置、补光措施及识别算法的设计,强调了实际应用场景中可能遇到的问题以及相应的解决方案。
基于AnythingLLM框架和Ollama环境本地运行deepseek,并可以通过用户自己的文档来针对性地回答用户问题,用户也可以上传文件来构建模型回复问题所需要的所有参考资料的知识库,使得模型相对于在线模型更加专业地解答用户的问题。同时本地部署保证了隐私性和针对性。
指针式表盘指针关键部位分割系统源码&数据集分享
多策略增强:MWOA鲸鱼优化算法与其他变体及2024年最新算法的实证比较与结果分析——新颖策略实施效果显著且复杂度无增加的研究,多策略改进的鲸鱼优化算法(MWOA),与其他三种变体和几种2024最新算法比较,策略都是很新颖的策略,可以直接写了发文章,并且没有增加复杂度上改进效果 ,MWOA; 变体算法; 最新算法; 策略新颖; 复杂度未增加; 改进效果显著,"多策略改进MWOA算法:与多种变体及2024新算法比较展示优越性"
织物缺陷检测系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]