2015-04-03 141 views
0

因爲我找不到我的代碼有什麼問題來使jssor滑塊響應。下面的代碼是從他們網站上的文檔中提取的,我已經檢查過很多次,但並不複雜,只是API $ScaleWidth()在頁面上沒有效果,如果您在函數外部使用它。你可以看到它住在這裏rickymignanego.com

我重複下面的腳本:

<script> 
jQuery(document).ready(function ($) { 
    var _CaptionTransitions = [];  
     _CaptionTransitions["oBelin"] = { 
      $Duration:1000, 
      $FlyDirection:2, 
      $Easing:{$Left:$JssorEasing$.$EaseOutBack}, 
      $ScaleHorizontal:0.6, 
      $Opacity:2 
      };   

     var options = {   
      $AutoPlay: false,    
      $CaptionSliderOptions: {     
        $Class: $JssorCaptionSlider$, 
        $CaptionTransitions: _CaptionTransitions, 
        $PlayInMode: 1,     
        $PlayOutMode: 3,       
        }, 

      $BulletNavigatorOptions: {         
       $Class: $JssorBulletNavigator$,      
       $ChanceToShow: 2,        
       $AutoCenter: 1,         
       $Steps: 1,          
       $Lanes: 1,          
       $SpacingX: 10,         
       $SpacingY: 10,         
       $Orientation: 1         
      }      
    };   
    var jssor_slider1 = new $JssorSlider$('home-teaser', options); 

    function ScaleSlider() { 
     var parentWidth = $('#home-teaser').parent().width(); 

     if (parentWidth) { 
      jssor_slider1.$ScaleWidth(parentWidth); 
     } 
     else 
      window.setTimeout(ScaleSlider, 30); 
    } 
    //Scale slider after document ready 
    ScaleSlider(); 

    //Scale slider while window load/resize/orientationchange. 
    $(window).bind("load", ScaleSlider); 
    $(window).bind("resize", ScaleSlider); 
    $(window).bind("orientationchange", ScaleSlider); 
});   

//jssor_slider1.$ScaleWidth(300); 
</script> 

回答

1

幹得好,恭喜你!

請通過以下步驟。

  1. $ ScaleWidth是一個新的API(前身爲$ SetScaleWidth),並且您使用的是舊版本jssor滑塊,請下載最新的。

  2. 的響應代碼是不是在您的網頁,請添加以下代碼,

    //responsive code begin 
    function ScaleSlider() { 
        var parentWidth = $('#home-teaser').parent().width(); 
    
        if (parentWidth) { 
         jssor_slider1.$ScaleWidth(parentWidth); 
        } 
        else 
         window.setTimeout(ScaleSlider, 30); 
    } 
    //Scale slider after document ready 
    ScaleSlider(); 
    
    //Scale slider while window load/resize/orientationchange. 
    $(window).bind("load", ScaleSlider); 
    $(window).bind("resize", ScaleSlider); 
    $(window).bind("orientationchange", ScaleSlider); 
    //responsive code end 
    
+0

非常感謝你的誇獎,併爲您的工作jssor是偉大的!現在正在工作。 – 3ky 2015-04-09 09:00:01