2015-04-03 81 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

相关问题