• 织梦 图片轮播-改


    <div  class="infiniteCarousels" style="float:left;margin-top:5px;"> 
    <div style="280px;height:180px;overflow:hidden;">
    <ul id='imgscrolls' >
    {dede:arclist row=4 orderby=pubdate type='image.' typeid='25' }
    <li style="float:left;display:inline;">
    <div style="position: relative;  400px; height:145px;color:white;">
    <img  src="[field:litpic/]" style="280px;height:180px">
    <span style="position:absolute; bottom:-35px; left:0; line-height:1.5; 280px; background-color:rgba(0,0,0,0.5);">[field:title/]</span>
    </div>
    {/dede:arclist}                   
    </li>
    </ul>
    </div>    
    </div>
    (function () {
        $.fn.infiniteCarousels = function () {
            function repeat(str, n) {
                return new Array( n + 1 ).join(str);
            }
            
            return this.each(function () {
                // magic!
                var $wrapper = $('> div', this).css('overflow', 'hidden'),
                    $slider = $wrapper.find('> ul').width(9999),
                    $items = $slider.find('> li'),
                    $single = $items.filter(':first')
                    
                    singleWidth = $single.outerWidth(),
                    visible = Math.ceil($wrapper.innerWidth() / singleWidth),
                    currentPage = 1,
                    pages = Math.ceil($items.length / visible);
                    
                /* TASKS */
                
                // 1. pad the pages with empty element if required
                if ($items.length % visible != 0) {
                    // pad
                    $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                    $items = $slider.find('> li');
                }
                
                // 2. create the carousel padding on left and right (cloned)
                $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
                $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
                $items = $slider.find('> li');
                
                // 3. reset scroll
                $wrapper.scrollLeft(singleWidth * visible);
                
                // 4. paging function
                function gotoPage(page) {
                    var dir = page < currentPage ? -1 : 1,
                        n = Math.abs(currentPage - page),
                        left = singleWidth * dir * visible * n;
                    
                    $wrapper.filter(':not(:animated)').animate({
                        scrollLeft : '+=' + left
                    }, 500, function () {
                        // if page == last page - then reset position
                        if (page > pages) {
                            $wrapper.scrollLeft(singleWidth * visible);
                            page = 1;
                        } else if (page == 0) {
                            page = pages;
                            $wrapper.scrollLeft(singleWidth * visible * pages);
                        }
                        
                        currentPage = page;
                    });
                }
                
                // 5. insert the back and forward link
                 //$wrapper.after('<a href="#" class="arrow back">1</a><a href="#" class="arrow forward">2</a>');
                
                // 6. bind the back and forward links
                $('a.back', this).click(function () {
                    gotoPage(currentPage - 1);
                    return false;
                });
                
                $('a.forward', this).click(function () {
                    gotoPage(currentPage + 1);
                    return false;
                });
                
                $(this).bind('goto', function (event, page) {
                    gotoPage(page);
                });
                
                // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
                $(this).bind('next', function () {
                    gotoPage(currentPage + 1);
                });
            });
        };
    })(jQuery);
    
    
    
    $(document).ready(function () {
        // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
        var autoscrolling = true;
        if($('#imgscrolls > li').length>0)
        {
            $('.infiniteCarousels').infiniteCarousels().mouseover(function () {
                autoscrolling = false;
            }).mouseout(function () {
                autoscrolling = true;
            });
            setInterval(function () {
                if (autoscrolling) {
                    $('.infiniteCarousels').trigger('next');
                }
            }, 5000);
    
        }
        
    });
  • 相关阅读:
    用友U8 | 【存货管理】提示用户***正在记账,不允许并发。
    用友U8 | 怎么准确查找【采购入库单】、【采购发票】,对应的凭证号?
    用友U8 | 中途启用序列号管理,该怎么操作?
    Excel:提取身份证号中的性别
    给jupyter 添加代码自动补全功能
    SQL函数之:截断字符串
    解决Maven子项目提示 ‘parent.relativePath‘ of POM
    公共NTP资源汇总
    iperf3的使用
    ZeroTier的使用
  • 原文地址:https://www.cnblogs.com/hellowzd/p/4246127.html
Copyright © 2020-2023  润新知