/**
 * 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. There is no Action mapped for namespace [/pages/action/student] and action name [findStudent]

    1.错误描写叙述 2014-7-13 2:38:54 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one ...

  2. 使用android x86进行android应用开发.

    首发论坛 安卓巴士.id:android_bin 一.必备工具: 1.虚拟机软件(本文使用virtual Box为例), 2.android x86镜像,下载地址http://www.android- ...

  3. python 源码解析

    http://blog.donews.com/lemur/archive/category/cpython%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90/

  4. [Effective C++ --005]了解C++默默编写并调用哪些函数

    <前言>编译器是个十分敬业的工作者,不但为你编译代码,甚至为你生成代码,不可思议吧.本文主要介绍编译器究竟会为我们生成和调用哪些代码. <空类和非空类>如果问什么样的类是空类? ...

  5. Asp.Net 之 基本控件FileUpload上传控件

    1.前台代码: <asp:FileUpload ID="FileUpload" runat="server" /> <asp:Button I ...

  6. MySQL创建/删除/清空表,添加/删除字段

    创建表: create table tablename (column_name column_type); create table table_name( id int not null auto ...

  7. Excel导入导出帮助类

    /// <summary>    /// Excel导入导出帮助类    /// 记得引入 NPOI    /// 下载地址   http://npoi.codeplex.com/rele ...

  8. 4.关于phpstudy for linux 的安装(LNMP)更好的环境请看8.LNMP环境

    phpstudy真的很坑爹! 所以我在后面重新写了一个LNMP环境的集成包应用! 首先,我们在自己本地开发的时候一般使用的虚拟机的权限账号都是最高的,也就是我们的root账户 PS:我已经更改镜像源为 ...

  9. 关于Git的暂存区这个概念的理解.

    Git中的暂存区成为stage或者是index.可以理解成一个"提交任务".Git暂存区是Git最成功的设计之一,但是也是最难理解的. 暂存区是一个介于工作区和版本库的中间状态.当 ...

  10. matlab中num2str的应用

    在求导数,积分,方程的过程中,难免会遇到一些参数要随着情况有点变化,这时,你就需要能够动态的表示出你的表达式,Num2str函数是一个相当有用的函数,一般配合[]连接符使用,下面将我接触到的一些用法写 ...