基于jquery的无缝循环新闻列表插件


Posted in Javascript onMarch 07, 2011

一、效果图:
基于jquery的无缝循环新闻列表插件
tips源码下载 http://xiazai.3water.com/201103/yuanma/jquerynewslist.rar
二、jquery源码:

(function($){ 
$.fn.extend({ 
newsList:function(options){ 
var defaults ={ 
actName:'li', //显示条数名; 
maxShowNum:'6', //最多的显示条数; 
actNameH:'28', //一次移动的距离; 
ulClass:'.ul_news_list', //被复制层的class 
copyUlClass:'.ul_news_list2', //复制层的class 
autoTime:'1500', //自动运行时间; 
clickGoUpC:'.go_uplist', //点击向上class; 
clickDownUpC:'.go_downlist', //点击向下class; 
goStart:'go_tart', 
autoCloss:'flase' //自动运行开关,当为'flase'时为开,其它则关; 
} ; options = $.extend(defaults, options); 
return this.each(function(){ 
var o = options; 
var counts =1; 
var linum = $($(this).find(o.actName),$(this)).size(); 
var ul_class = $($(this).find(o.ulClass),$(this)); 
var copy_ul_class = $($(this).find(o.copyUlClass),$(this)); 
var click_go_up_c = $($(this).find(o.clickGoUpC),$(this)); 
var click_go_down_C = $($(this).find(o.clickDownUpC),$(this)); 
var go_start = $($(this).find(o.goStart),$(this)); 
if(linum > o.maxShowNum){ 
$(copy_ul_class).html($(ul_class).html()); 
goStartList(); 
} 
var thiswrap = $($(ul_class).parent().parent(),$(this)); 
//自动运行函数 
function auto_function(){ 
if(counts <= linum){ 
$(ul_class).animate({top:'-=' + o.actNameH},o.autoTime); 
$(copy_ul_class).animate({top:'-=' + o.actNameH},o.autoTime); 
counts++; 
}else{ 
$(ul_class).animate({top:0},0); 
$(copy_ul_class).animate({top:0},0); 
counts = 1; 
} 
} 
//点击向上移动时; 
if(linum > o.maxShowNum){ 
$(click_go_up_c).click(function(){ 
if(counts <= linum){ 
$(ul_class).animate({top:'-=' + o.actNameH},0); 
$(copy_ul_class).animate({top:'-=' + o.actNameH},0); 
counts++; 
}else{ 
$(ul_class).animate({top:0},0); 
$(copy_ul_class).animate({top:0},0); 
counts = 1; 
} 
}); 
} 
//点击向下移动时; 
if(linum > o.maxShowNum){ 
$(click_go_down_C).click(function(){ 
if(counts > 1){ 
counts--; 
$(ul_class).animate({top:'-'+ counts*o.actNameH},0); 
$(copy_ul_class).animate({top:'-'+ counts*o.actNameH},0); 
}else{ 
$(ul_class).animate({top:0},0); 
$(copy_ul_class).animate({top:0},0); 
counts = linum+1; 
} 
}); 
} 
//鼠标经过所发生的开始停止; 
if(linum > o.maxShowNum){ 
$(thiswrap).hover(function(){ 
goStopList(); 
},function(){ 
goStartList(); 
}); 
} 
function goStartList(){ 
if(o.autoCloss === 'flase'){ 
go_start = setInterval(auto_function,o.autoTime); 
} 
} 
function goStopList(){ 
clearInterval(go_start); 
} 
}); 
} 
}); 
}(jQuery));

三、HTML:
<script language="javascript"> 
$(document).ready(function(){ 
$("#newslist").newsList(); 
}); 
</script> <div id="newslist"> 
<div class="go_upanddown"><span class="go_uplist"><img src="images/newslist/goupbtn.gif" /></span><span class="go_downlist"><img src="images/newslist/godownbtn.gif" /></span></div> 
<div class="news_list_bar"> 
<ul class="ul_news_list"> 
<li><a href="#">1、曾参加过唐山、汶川、玉树地震救援的援</a><a href="#">曾参加过唐,又来到了舟曲参加救援</a></li> 
<li><a href="#">2、摩洛哥塞拉,艺术家在一场为流浪儿童为流浪儿童为流浪儿童为流浪儿童募捐的马戏节目中表演</a></li> 
<li><a href="#">3、昆明警方近日县的“洪兴甸县的“洪兴甸县的“洪兴甸县的“洪兴帮”黑恶势力团伙,缴获...</a></li> 
<li><a href="#">4、印度克什知自己的孩子在骚乱中丧生时痛不欲生..</a><a href="#">曾参加过唐曾参加过唐到了舟曲参加救援</a></li> 
<li><a href="#">5、明昆明警方近日捣毁了寻甸县的“洪兴帮”黑恶势力团伙,缴获...</a></li> 
<li><a href="#">6、曾参加过唐曾参加过唐曾参加过唐曾参加过唐</a></li> 
<li><a href="#">7、湖北武汉汉口汉口曾参加过唐曾参加过唐曾参加过唐曾参加过唐观看两江洪峰过</a></li> 
<li><a href="#">8、湖北武汉汉曾参加过唐曾参加过唐曾参加过唐曾参加过唐集在江边观</a></li> 
<li><a href="#">9、湖北武汉汉口汉口龙王庙景区观景平台上,市民聚集在江边观看两江洪峰过汉</a></li> 
</ul> 
<ul class="ul_news_list2"></ul> 
</div> 
</div>

四、CSS:
body { font-family:"微软雅黑",Arial,"Lucida Grande", Verdana, Lucida; font-size:12px; } 
*{ padding:0; margin:0;} 
img { border:0;} 
.clear { clear:both;} 
a { color:#000; text-decoration:none;} 
a:hover { color:#EC6104; text-decoration:none;} 
.undis { display:none;}/*news_list*/ 
.news_list_bar { position:relative; width:560px; height:168px; overflow:hidden; background:url(../images/slideshow2/v3_picture6.gif) repeat-y; background-color:#F00;} 
.ul_news_list, 
.ul_news_list2{ position:relative; list-style:none;} 
.ul_news_list li, 
.ul_news_list2 li{line-height:28px; height:28px; width:500px; overflow:hidden; white-space:nowrap;padding:0 20px;} 
.ul_news_list li a, 
.ul_news_list2 li a{ padding-right:20px;} 
.go_upanddown { position:absolute; margin:-20px 0 0 500px;} 
.go_upanddown span { padding-right:10px; cursor:pointer;}
Javascript 相关文章推荐
jquery text()要注意啦
Oct 30 Javascript
JavaScript 申明函数的三种方法 每个函数就是一个对象(一)
Dec 04 Javascript
jQuery的Ajax的自动完成功能控件简要说明
Feb 22 Javascript
详解javascript实现瀑布流列式布局
Jan 29 Javascript
浅谈js基本数据类型和typeof
Aug 09 Javascript
想学习javascript JS和jQuery哪个重要 先学哪个
Dec 11 Javascript
jQuery实现对象转为url参数的方法
Jan 11 Javascript
angular指令笔记ng-options的使用方法
Sep 18 Javascript
使用pkg打包Node.js应用的方法步骤
Oct 19 Javascript
JS中的防抖与节流及作用详解
Apr 01 Javascript
使用VueRouter的addRoutes方法实现动态添加用户的权限路由
Jun 03 Javascript
vue+elementUI 复杂表单的验证、数据提交方案问题
Jun 24 Javascript
JavaScript对象之间的转换 jQuery对象和原声DOM
Mar 07 #Javascript
jQuery总体架构的理解分析
Mar 07 #Javascript
关于捕获用户何时点击window.onbeforeunload的取消事件
Mar 06 #Javascript
js中将具有数字属性名的对象转换为数组
Mar 06 #Javascript
js 优化次数过多的循环 考虑到性能问题
Mar 05 #Javascript
淘宝搜索框效果实现分析
Mar 05 #Javascript
再论Javascript下字符串连接的性能
Mar 05 #Javascript
You might like
一些常用的php函数
2006/12/06 PHP
使ecshop模板中可引用常量的实现方法
2011/06/02 PHP
php通过strpos查找字符串出现位置的方法
2015/03/17 PHP
PHP三种方式实现链式操作详解
2017/01/21 PHP
最新28个很棒的jQuery 教程
2011/05/28 Javascript
javascript改变position值实现菜单滚动至顶部后固定
2013/01/18 Javascript
javascript继承机制实例详解
2014/11/20 Javascript
jQuery实现div横向拖拽排序的简单实例
2016/07/13 Javascript
微信小程序 http请求详细介绍
2016/10/09 Javascript
js实现手机拍照上传功能
2017/01/17 Javascript
基于 Vue.js 之 iView UI 框架非工程化实践记录(推荐)
2017/11/21 Javascript
微信小程序左右滑动的实现代码
2017/12/15 Javascript
详解如何在vue-cli中使用vuex
2018/08/07 Javascript
vue根据进入的路由进行原路返回的方法
2018/09/26 Javascript
微信小程序云开发如何实现数据库自动备份实现
2019/08/16 Javascript
Js跳出两级循环方法代码实例
2020/09/22 Javascript
js重写alert事件(避免alert弹框标题出现网址)
2020/12/04 Javascript
[25:59]Newbee vs TNC 2018国际邀请赛小组赛BO2 第二场 8.16
2018/08/17 DOTA
Python3使用requests发闪存的方法
2016/05/11 Python
python结合selenium获取XX省交通违章数据的实现思路及代码
2016/06/26 Python
使用Python操作excel文件的实例代码
2017/10/15 Python
用python制作游戏外挂
2018/01/04 Python
Python实现多属性排序的方法
2018/12/05 Python
Python matplotlib生成图片背景透明的示例代码
2019/08/30 Python
python安装scipy的步骤解析
2019/09/28 Python
python3中的logging记录日志实现过程及封装成类的操作
2020/05/12 Python
给keras层命名,并提取中间层输出值,保存到文档的实例
2020/05/23 Python
python3爬虫中多线程的优势总结
2020/11/24 Python
FORZIERI澳大利亚站:全球顶级奢华配饰精品店
2016/12/31 全球购物
微观物理专业自荐信
2014/01/26 职场文书
优秀求职信范文分享
2014/01/26 职场文书
2015年世界无烟日活动方案
2015/05/04 职场文书
军事博物馆观后感
2015/06/05 职场文书
利用Python读取微信朋友圈的多种方法总结
2021/08/23 Python
SpringBoot使用AOP实现统计全局接口访问次数详解
2022/06/16 Java/Android
Windows Server 版本 20H2 于 8 月 9 日停止支持,Win10 版本 21H1 将于 12 月结束支
2022/07/23 数码科技