2016-06-08 41 views
0

我的猫头鹰传送带上的afterAction函数有问题。 问题是afterAction:当动作“function(current)”在代码中的第二个时,syncPosition不起作用。如果我删除它,syncPosition就起作用。如何玩OwlCarousel中的两个afterActions

目前我无法做一个小提琴,但也许你们中的一些人可以看到拼写错误或下面的东西。

UPDATE //整个代码

$(document).ready(function() { 
    $(".owl-carousel").owlCarousel({ 
    loop: false, 
    navigation: true, 
    pagination: true, 
    paginationSpeed: 1000, 
    singleItem: true, 
    transitionStyle: "mask", 
    autoHeight: true, 
    autoPlay: 10000, //Set AutoPlay to 3 seconds 
    navigationText : false, 
    afterAction: syncPosition, 
    afterAction: function(current) { 
     current.find('video').get(0).play(); 
    } 
    }); 

    function syncPosition(el) { 
    var current = this.currentItem; 
    // code for smooth transition 
    this.owl.owlItems.removeClass('turn-on'); 
    var t = this; 

    $(this.owl.owlItems[this.owl.currentItem]).addClass('turn-on'); 
    } 

}); 

$(window).scroll(function() { 
    if ($(this).scrollTop() > 80) { 
    $('.owl-pagination').addClass('hidden'); 
    } else { 
    $('.owl-pagination').removeClass('hidden'); 
    } 
}); 

回答

0

我已经改变了

afterAction: function(current) { 
current.find('video').get(0).play(); 
} 

afterInit: function(){ 
$("#sequence-1").find('video').get(0).play(); 

两者syncPosition.find('video').get(0).play(); 都在工作。