2014-01-10 183 views
9

我爲我的滑塊使用了OWL Carousel在OWL Carousel中滑動2個項目

我想要做的是當下一個上一個被點擊時滑動2個項目。

因此,它滑動到每個第二個項目仍然顯示在傳輸過程中的第二個項目。

我試圖用CSS解決它,但沒有成功。

這裏是我的基本設置

$("#owl-demo").owlCarousel({ 

    navigation : true, // Show next and prev buttons 
    slideSpeed : 600, 
    paginationSpeed : 400, 
    singleItem:true, 

    // "singleItem:true" is a shortcut for: 
    // items : 2 
    // itemsDesktop : false, 
    // itemsDesktopSmall : false, 
    // itemsTablet: false, 
    // itemsMobile : false 

});

任何幫助非常感謝。

在此先感謝。

回答

3

在當前版本的貓頭鷹傳送帶(1.3.2)中,找到「owl.carousel.js」文件並滾動到第558行。該生產線將改爲:

base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1; 

更改的最後一個號碼爲「2」,這樣記載:

base.currentItem += base.options.scrollPerPage === true ? base.options.items : 2; 

保存文件,並應由兩個項目使滑塊移動。

+0

它不是好主意,更新插件。任何其他方式都有更新。貓頭鷹旋轉木馬版本1.3.3 – sibaspage

0

對於下一步按鈕,

//base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1; 
To 
base.currentItem += base.options.scrollPerPage === true ? base.options.items : 2; 

對於上一個按鈕,

//base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1; 
To 
base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 2; 
15
scrollPerPage : true 

這可能有助於

7
jQuery(".view-id-frontpage .view-content").owlCarousel({ 
    items: 2, 
    itemsDesktop : [1000,2], // 2 items between 1000px and 901px 
    itemsDesktopSmall : [900,2], // betweem 900px and 601px 
    itemsTablet: [700,1], // 2 items between 600 and 480 
    itemsMobile : [479,1] , // 1 item between 479 and 0 
    navigation: true, 
    lazyLoad: true, 
    pagination: false, 
    scrollPerPage : true 
}); 

這幫助了我。

18

不要更改插件代碼,您只需要使用slideBy選項初始化輪播,如下所述。

//Initialize Plugin 
$(".owl-carousel").owlCarousel(
    { 
    slideBy: 4 
    } 
); 
+0

用貓頭鷹旋轉木馬v2.0.0完美適合我。該選項在響應設置中也可用。 – webster

2

以上答案很有幫助,但不完整。在owl.carousel.js

base.currentItem += base.options.scrollPerPage === true ? base.options.items : 2; 

更換線路559:

更換558線在owl.carousel.js

if (base.currentItem > base.maximumItem + (base.options.scrollPerPage === true ? (base.options.items - 1) : 0)) { 

這將使得轉盤滾動2點擊下一步,但當用戶單擊prev按鈕時仍然需要考慮。以下將做到這一點

替換line 581 in owl.carousel。JS有:

base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 2; 

現在,你需要考慮奇數在旋轉木馬項目,因此它會通過點擊每一個項目的所有道路。

在上一步直屬的代碼添加上線582這樣的代碼:

if (base.currentItem === -1) base.currentItem = 0; 

我希望這幫助。

1
Slide 2 items in OWL Carousel 

Check this Example 

http://jsfiddle.net/k0nn7yw5/107/

+0

請回答一些解釋。 –

+0

完整的腳本bnaya h,是k ilawa kesi信息chahiye bro? –

相關問題