猫头鹰旋转木马 - 多个滑块导致页面在加载时冻结

时间:2014-08-23 17:43:48

标签: javascript jquery slider carousel owl-carousel

我在WordPress主题上使用owl carousel。首页显示3个转盘 - 内页显示第4个。

在加载首页时,它不会响应任何鼠标操作大约1-2秒。它像大多数CPU一样使用,但它加载很好。我可以在下面的代码中更改某些内容以改善性能吗?

        (function($) {
            $(document).ready(function() { 
                $('.tooltip-link').tooltip({ placement: 'top'});

                var owl1 = $(".carousel-one");
                owl1.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause') . '000'; } ?>,
                  pagination:false,
                  itemsDesktop :    [2500,2],
                  itemsDesktopSmall :   [1000,2],
                  itemsMobile :     [679,1],
                  mouseDrag: false,
                  touchDrag: false
                }); 
                $(".carousel-one-next").click(function(){
                    owl1.trigger('owl.next');
                })
                $(".carousel-one-prev").click(function(){
                    owl1.trigger('owl.prev');
                })

                var owl2 = $(".carousel-two");
                owl2.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause2') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause2') . '000'; } ?>,
                  pagination:true,
                  itemsDesktop :    [2500,4],
                  itemsDesktopSmall :   [1000,3],
                  itemsMobile :     [679,2],
                  mouseDrag: false,
                  touchDrag: false                    
                }); 
                $(".carousel-two-next").click(function(){
                    owl2.trigger('owl.next');
                })
                $(".carousel-two-prev").click(function(){
                    owl2.trigger('owl.prev');
                })  

                var owl3 = $(".carousel-three");
                owl3.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause3') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause3') . '000'; } ?>,
                  pagination:false,
                  itemsDesktop :    [2500,3],
                  itemsDesktopSmall :   [1000,3],
                  itemsMobile :     [679,2],
                  mouseDrag: false,
                  touchDrag: false                    
                }); 
                $(".carousel-three-next").click(function(){
                    owl3.trigger('owl.next');
                })
                $(".carousel-three-prev").click(function(){
                    owl3.trigger('owl.prev');
                })

                var owl4 = $(".carousel-four");
                owl4.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause4') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause4') . '000'; } ?>,
                  pagination:true,
                  singleItem : true,
                  autoHeight : true,
                  mouseDrag: false,
                  touchDrag: false                    
                }); 
                $(".carousel-four-next").click(function(){
                    owl4.trigger('owl.next');
                })
                $(".carousel-four-prev").click(function(){
                    owl4.trigger('owl.prev');
                })                              
            });
        })(jQuery);

0 个答案:

没有答案