Jssor Slider - 如何禁用缩放?

时间:2015-03-24 16:58:50

标签: scaling jssor

我刚刚发现了Jssor Slider。 太棒了。 快问。 如何禁用内置缩放? 谢谢, d

2 个答案:

答案 0 :(得分:1)

打开包中的任何模板,您可能会看到以下代码。

//responsive code begin
//you can remove responsive code if you don't want the slider scales while window resizes
function ScaleSlider() {
    var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
    if (parentWidth)
        jssor_slider1.$ScaleWidth(Math.min(parentWidth, 600));
    else
        window.setTimeout(ScaleSlider, 30);
}
ScaleSlider();

$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end

这是在窗口调整大小时缩放滑块的代码。如果您不需要此功能,请将其删除。

答案 1 :(得分:1)

Jssor有一个选项FillMode,设置为5.我使用并且对主图像和缩略图都很好。

/* Main Slider Section */

                var options_slider1 = {
                    $AutoPlay : false, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
                    $PauseOnHover : 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1

                    $DragOrientation : 3, //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
                    $ArrowKeyNavigation : true, //[Optional] Allows keyboard (arrow key) navigation or not, default value is false
                    $SlideDuration : 600, //Specifies default duration (swipe) for slide in milliseconds

                    $SlideshowOptions : {//[Optional] Options to specify and enable slideshow or not
                        $Class : $JssorSlideshowRunner$, //[Required] Class to create instance of  transitions to play slideshow
                        $TransitionsOrder : 1, //[Optional] The way to choose transition to play slide, 1 Sequence, 0 Random
                        $ShowLink : true //[Optional] Whether to bring slide link on top of the slider when slideshow is running, default value is false
                    },

                    $ArrowNavigatorOptions : {//[Optional] Options to specify and enable arrow navigator or not
                        $Class : $JssorArrowNavigator$, //[Requried] Class to create arrow navigator instance
                        $ChanceToShow : 1, //[Required] 0 Never, 1 Mouse Over, 2 Always
                        $AutoCenter : 2, //[Optional] Auto center navigator in parent container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
                        $Steps : 1 //[Optional] Steps to go for each navigation request, default value is 1
                    },

                    $ThumbnailNavigatorOptions : {//[Optional] Options to specify and enable thumbnail navigator or not
                        $Class : $JssorThumbnailNavigator$, //[Required] Class to create thumbnail navigator instance
                        $ChanceToShow : 2, //[Required] 0 Never, 1 Mouse Over, 2 Always

                        $ActionMode : 1, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1
                        $Lanes : 1, //[Optional] Specify lanes to arrange thumbnails, default value is 1
                        $SpacingX : 14, //[Optional] Horizontal space between each thumbnail in pixel, default value is 0
                        $SpacingY : 12, //[Optional] Vertical space between each thumbnail in pixel, default value is 0
                        $Cols: 6, //[Optional] Number of pieces to display, default value is 1
                        $Align: 156, //[Optional] The offset position to park thumbnail
                        $Orientation : 2 //[Optional] Orientation to arrange thumbnails, 1 horizental, 2 vertical, default value is 1
                    },

                    $FillMode: 5, //    The way to fill image in slide, 0: stretch, 1: contain (keep aspect ratio and put all inside slide), 2: cover (keep aspect ratio and cover whole slide), 4: actual size, 5: contain for large image and actual size for small image, default value is 0
                };

                var jssor_slider1 = new $JssorSlider$("slider1_container", options_slider1);
                //responsive code begin
                //you can remove responsive code if you don't want the slider scales while window resizes
                function ScaleSlider() {
                    $('#listing_template_wraper').width($(window).width());
                    var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
                    if (parentWidth)
                        jssor_slider1.$ScaleWidth(Math.max(Math.min(parentWidth, 960), 300));
                    else
                        window.setTimeout(ScaleSlider, 30);
                }

                ScaleSlider();

                $(window).bind("load", ScaleSlider);
                $(window).bind("resize", ScaleSlider);
                $(window).bind("orientationchange", ScaleSlider);

                /* End Main Slider Section */