zoukankan      html  css  js  c++  java
  • 基于jq, jquery.easie.js 开发面向对象通栏焦点图组件

    <!--banner begin-->
    <div class="banner min_width" id="one" style="">
    <span class="foucL fouc"></span>
     <ul>
       <li style="background: url(./images/banner.jpg) no-repeat center top; height:454px;"><a href=""></a></li>
       <li style="background: url(./images/banner1.jpg) no-repeat center top; height:454px;"><a href=""></a></li>
       <li style="background: url(./images/banner2.jpg) no-repeat center top; height:454px;"><a href=""></a></li>
     </ul>
     <span class="foucR fouc"></span>
    
        <div class="foucdocs"></div>
    </div>
    <!--banner end-->
    <script>
        $(function(){
            Scroll({
                dome:$('#one'),
                next:$('.foucL'),
                pre:$('.foucR')
            });
        })
    </script>
    ;
    (function ($, window, document, undefined) {
        function scroll() {
            this.num = 0;
            this.obj = this;
            this.dome = null;
            this.dome_ul = null;
            this.dome_li_lent = null;
            this.full_wit = null;
            this.timer = null;
            this.next = null;
            this.pre = null;
            this.settings = {
                times: 2000,
                way_annimate: 'ease-out',
            };
    
        }
    
        scroll.prototype.init = function (opt) {
            var This = this;
            var pos_left = null;
            this.options = $.extend({}, this.settings, opt)
            this.dome = this.options.dome;
            this.dome_ul = this.dome.find('ul');
            this.dome_ul.append(this.dome_ul.find('li:first').clone())
            this.dome_li_lent = this.dome_ul.find('li').length;
    
            for (var b = 0; b < this.dome_li_lent; b++) {
                this.dome.find('.foucdocs').append('<span></span>');
            }
    
    
            this.dome.find('.foucdocs span').eq(0).addClass('focus_on');
            this.next = this.dome.find(this.options.next);
            this.pre = this.dome.find(this.options.pre);
            this.getwidth();
            this.timer = setInterval(gos, This.options.times);
            $(window).resize(function () {
                This.getwidth();
            })
            this.dome.hover(function () {
                This.next.show();
                This.pre.show();
                clearInterval(This.timer);
            }, function () {
                This.next.hide();
                This.pre.hide();
                This.timer = setInterval(gos, This.options.times);
            })
    
            function gos() {
                This.num++;
                if (This.num > (This.dome_li_lent - 1)) {
                    This.num = 0;
                }
                This.dome.find('.foucdocs span').eq(This.num).addClass('focus_on').siblings('span').removeClass('focus_on')
                pos_left = (This.full_wit * This.num);
                This.dome_ul.stop().animate({left: -pos_left + 'px'}, This.options.way_annimate);
            }
            this.dome.find('.foucdocs span').mouseover(function () {
                This.num=$(this).index();
                pos_left = (This.full_wit * This.num);
                This.dome_ul.stop().animate({left: -pos_left + 'px'}, This.options.way_annimate);
                $(this).addClass('focus_on').siblings('span').removeClass('focus_on');
            })
            this.next.click(function () {
                gos();
            })
            this.pre.click(function () {
                This.num--;
                if (This.num < 0) {
                    This.num = This.dome_li_lent - 1;
                    console.log(This.num)
                }
                This.dome.find('.foucdocs span').eq(This.num).addClass('focus_on').siblings('span').removeClass('focus_on');a
                pos_left = (This.full_wit * This.num);
                This.dome_ul.stop().animate({left: -pos_left + 'px'}, This.options.way_annimate);
            })
        }
    
    
        scroll.prototype.getwidth = function () {
            this.full_wit = $(window).width();
            this.dome_ul.css({
                 this.full_wit * this.dome_li_lent + 'px',
            })
            this.dome_ul.find('li').css({
                 this.full_wit + 'px',
            })
        }
    
    
        window.Scroll = function (opt) {
            var litscoll = new scroll();
            litscoll.init(opt);
    
        }
    })(jQuery, window, document);
    git仓库地址:https://github.com/XINYUHAI77/jquery_full
  • 相关阅读:
    CodeForces 510C Fox And Names (拓扑排序)
    Codeforces 1153D Serval and Rooted Tree (简单树形DP)
    HDU 6437 Problem L.Videos (最大费用)【费用流】
    Luogu P3381 (模板题) 最小费用最大流
    Codeforces 741B Arpa's weak amphitheater and Mehrdad's valuable Hoses (并查集+分组背包)
    Codeforces 1144F Graph Without Long Directed Paths (DFS染色+构造)
    HDU 2204 Eddy's 爱好 (容斥原理)
    Codeforces 939E Maximize! (三分 || 尺取)
    Codeforces 938D. Buy a Ticket (最短路+建图)
    CodeForces 959E Mahmoud and Ehab and the xor-MST (MST+找规律)
  • 原文地址:https://www.cnblogs.com/yexiangwang/p/5420651.html
Copyright © 2011-2022 走看看