/**
 * jQuery.hhNewSilder 滚动图片插件
 * User: huanhuan
 * QQ: 651471385
 * Email: th.wanghuan@gmail.com
 * 微博: huanhuan的天使
 * Date: 13-7-4
 * Time: 下午5:20
 * Dependence jquery-1.7.2.min.js
 */
 
 
$(function(){
 
$.fn.hhNewSilder = function(infor){
        var defaults = {
            autoTimer:6000,
speed:1000,
            picBox:'thDSpic',
            circleBox:'thDSnumber',
            leftEle:'thDSprev',
            rightEle:'thDSnext',
            preLoadSrc:'images/loading.gif',
            autoPlay:true,
            imgBox:function(){return GetBox();},
            imgBoxSize:function(){return GetSize();}
        };
 
        var option = $.extend(defaults, infor || {}),
            circleLi = option.imgBox().circleLi,
            imgList = option.imgBox().imgList,
            imgSize = option.imgBoxSize(),
            _thisAll = $(this),
            n = 1;
 
        $('.'+option.circleBox).find('li:eq(0)').addClass('thScrusor');
        //拿到li
        function GetBox(){
            this.circleLi = $('.'+option.circleBox,_thisAll).find("li");
            this.imgList =$('.'+option.picBox,_thisAll).find("li");
            return this;
        }
 
        //设置宽度、高度
        function GetSize(){
            this.w = $('.'+option.picBox,_thisAll).width();
            this.h = $('.'+option.picBox,_thisAll).height();
            return this;
        }
        var s = GetSize;
        s.w
 
        //设置ul的宽度
        $('.'+option.picBox, _thisAll).find('ul').css({
            width : imgList.width() * imgList.length
        });
 
        /*function getSiz(){
            var w = $('.'+option.picBox,_thisAll).width();
            var h = $('.'+option.picBox,_thisAll).height();
            return { w: w, h: h}
        }
        var size = getSiz();
        size.w*/
 
        return this.each(function(){
            //初始化时给li添加class="show"
            imgList.eq(0).addClass('show').css({'left':0}).siblings().removeClass('show').css({'left':imgSize.w});
 
            function Play(){
                if(imgList.is(':animated')) return; //如果在运动则返回
                var _index = $('.'+option.picBox).find('li.show').index(); //得到当前的
                _index = _index == "-1" ? 0 : _index;
                if(imgList.eq(n).hasClass('show')) return; //如果有show class则返回
                circleLi.eq(n).addClass('thScrusor').siblings().removeClass('thScrusor'); //圆点
                imgList.slice(_index,_index+1).animate({'left':-imgSize.w},option.speed,function(){
                    $(this).css({'left':imgSize.w});
                }).removeClass('show');
                imgList.eq(n).animate({left:0},option.speed).addClass('show'); //当前li添加show属性
                //追加
                if(imgList.length-1>n){
                    n++;
                }else{
                    n=0;
                }
            }
            _init = function(){
                var x=null;
                $('.'+option.picBox).find('li:gt(0)').css('left',imgSize.w);
                if(option.autoPlay) x=setInterval(Play,option.autoTimer);
                circleLi.click(function(){
                    n = $(this).index();
                    Play();
                    if(option.autoPlay){
                        clearInterval(x);
                        x=setInterval(Play,option.autoTimer);
                    }
                });
 
                //左右按钮绑定事件
                $('.'+option.leftEle+',.'+option.rightEle).css({'opacity':'0.3'}).live({
                    mouseover:function(){
                        $(this).stop(true,false).animate({'opacity':'1'},400);
                    },
                    mouseout:function(){
                        $(this).stop(true,false).animate({'opacity':'0.3'},400);
                    },
                    click:function(){
                        var _index = $('.'+option.picBox).find('li.show').index();
                        if($(this).attr('class')==option.leftEle){
                            n = _index==0?(imgList.length-1):_index-1;
                        }else{
                            n = _index==(imgList.length-1)?0:_index+1;
                        }
                        Play();
                        if(option.autoPlay){
                            clearInterval(x);
                            x=setInterval(Play,option.autoTimer);
                        }
                    }
                });
 
            }
            return _init();
        });
}
});

jQuery.hhNewSilder 滚动图片插件的更多相关文章

  1. jQuery.hhLRSlider 左右滚动图片插件

    /**  * jQuery.hhLRSlider 左右滚动图片插件  * User: huanhuan  * QQ: 651471385  * Email: th.wanghuan@gmail.com ...

  2. jQuery页面滚动图片等元素动态加载实现

    一.关于滚动显屏加载 常常会有这样子的页面,内容很丰富,页面很长,图片较多.比如说光棍节很疯狂的淘宝商城页面. 或者是前段时间写血本买了个高档耳机的京东商城页面,或者是新浪微博之类. 这些页面图片数量 ...

  3. [转]jQuery页面滚动图片等元素动态加载实现

    本文转自:http://www.zhangxinxu.com/wordpress/?p=1259 一.关于滚动显屏加载 常常会有这样子的页面,内容很丰富,页面很长,图片较多.比如说光棍节很疯狂的淘宝商 ...

  4. 自己写一个jQuery垂直滚动栏插件(panel)

    html中原生的滚动栏比較难看,所以有些站点,会自己实现滚动栏,导航站点hao123在一个側栏中,就自己定义了垂直滚动栏,效果比較好看,截图例如以下: watermark/2/text/aHR0cDo ...

  5. [JQuery]ScrollMe滚动特效插件

    最近考完试,一切顺利,昨晚闲着无聊把最近要用的一个插件翻译了一下:ScrollMe. (╯‵□′)╯︵┻━┻地址请戳: /* ScrollMe -李明夕翻译(╯‵□′)╯︵┻━┻ */ ScrollM ...

  6. jQuery scrollFix滚动定位插件

    [插件功能] 当用户向上或向下滚动页面到一定位置时,目标元素开始固定定位(position:fixed),当回滚到原位置时目标元素恢复到原状态,可以定制触发滚动相对屏幕位置和触发滚动方向,兼容IE6 ...

  7. 页面滚动图片等元素动态加载插件jquery.scrollLoading.js

    如果一个网页很长,那么该页面的加载时间也会相应的较长.而这里给大家介绍的这个jQuery插件scrollLoading的作用则是,对页面元素进行动态加载,通俗的说就是滚到哪就加载到哪,屏幕以下看不见的 ...

  8. 利用jQuery无缝滚动插件liMarquee实现图片(链接)和文字(链接)向右无缝滚动(兼容ie7+)

    像新闻类的版块经常要求一条条的新闻滚动出现,要实现这种效果,可以使用jQuery无缝滚动插件liMarquee. 注意: 1. 它的兼容性是IE7+,及现代浏览器. 2. 引用的jquery的版本最好 ...

  9. jquery 单行滚动、批量多行滚动、文字图片翻屏滚动效果代码

    jquery单行滚动.批量多行滚动.文字图片翻屏滚动效果代码,需要的朋友可以参考下. 以下代码,运行后,需要刷新下,才能加载jquery,要不然看不到效果.一.单行滚动效果 <!DOCTYPE ...

随机推荐

  1. iOS开发——网络编程OC篇&(一)XMPP简单介绍与准备

    XMPP简单介绍与准备 一.即时通讯简单介绍 1.简单说明 即时通讯技术(IM)支持用户在线实时交谈.如果要发送一条信息,用户需要打开一个小窗口,以便让用户及其朋友在其中输入信息并让交谈双方都看到交谈 ...

  2. Ambiguous mapping found. Cannot map 'xxxxController' bean method

    1.背景 今天要做一个demo,从github上clone一个springmvc mybatis的工程(https://github.com/komamitsu/Spring-MVC-sample-u ...

  3. MySql添加用户,新建数据库,用户授权,删除用户,修改密码

    转自:http://www.cnblogs.com/fly1988happy/archive/2011/12/15/2288554.html MySql中添加用户,新建数据库,用户授权,删除用户,修改 ...

  4. Android_Menu_contextMenu

    xml文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns ...

  5. How to use Oprofile tool to analysis program's performance

    You can get Oprofile RPM from https://www.rpmfind.net/ How to use Oprofile tools: Get report Steps: ...

  6. Matlab中tic和toc用法

    简单地说,tic和toc是用来记录matlab命令执行的时间 tic用来保存当前时间,而后使用toc来记录程序完成时间. 两者往往结合使用,用法如下: tic operations toc 显示时间单 ...

  7. nodejs设置NODE_ENV环境变量

    看下app.js文件中的一部分代码,如下: //开发环境错误处理 // will print stacktrace if (app.get('env') === 'development') { ap ...

  8. Javascript日期处理类库Moment.js

    1.组件详情地址Moment.js中文网 http://momentjs.cn/ 2.几个方法: (1) 日期格式化 moment().format(); // 2016-02-29T14:03:30 ...

  9. job interview

    一 , 7series clock 二, SDRAM comtroller (DDR) 4.熟悉DDR2/3协议或Ethernet相关协议,并有实际项目经验者优先: 三,AXI bus(AMBA) 四 ...

  10. Margin的垂直外边距问题

    做练习的时候遇到一个margin的问题,代码结构如下,给父元素body中的子元素div设置了margin:50px auto;本来我是想让子元素div距离父元素上边拉开50个像素,结果却是子元素div ...