JSSOR Captions同时触发所有幻灯片

时间:2014-09-10 06:50:40

标签: javascript jquery html css

我使用JSSOR为带幻灯片的幻灯片构建了以下代码。

但由于某些原因,所有字幕同时触发。

我希望每次点击幻灯片时都会触发相关字幕。

更详细地解释一下。如果我单击幻灯片1,然后快速滑到幻灯片2上,我会看到幻灯片2标题过渡的结束。但它似乎只在页面加载时触发一次。我希望它在选择幻灯片时运行。

这是我的JSSOR代码

    jQuery(document).ready(function ($) {

        var nestedSliders = [];
        var _CaptionTransitions = [];

        _CaptionTransitions["transition_name1"] = {$Duration:350,$FlyDirection:3,$Easing:{$Left:$JssorEasing$.$EaseInOutSine},$ScaleHorizontal:0.6,$Opacity:2};
        _CaptionTransitions["transition_name2"] = {$Duration: 1000, $FlyDirection: 1, $Easing: $JssorEasing$.$EaseOutCubic }

        $.each(["sliderh1_container", "sliderh2_container", "sliderh3_container","sliderh4_container", "sliderh5_container", "sliderh6_container"], function (index, containerId) {
            var nestedSliderOptions = {
                $PauseOnHover: 0,                               //[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, default value is 1
                $SlideDuration: 500,                                //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
                $MinDragOffsetToSlide: 20,                          //[Optional] Minimum drag offset to trigger slide , default value is 20
                //$SlideWidth: 200,                                   //[Optional] Width of every slide in pixels, default value is width of 'slides' container
                //$SlideHeight: 150,                                //[Optional] Height of every slide in pixels, default value is height of 'slides' container
                $SlideSpacing: 3,                                   //[Optional] Space between each slide in pixels, default value is 0
                $DisplayPieces: 1,                                  //[Optional] Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), the default value is 1
                $ParkingPosition: 0,                              //[Optional] The offset position to park slide (this options applys only when slideshow disabled), default value is 0.
                $UISearchMode: 0,                                   //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc).

                $BulletNavigatorOptions: {                                //[Optional] Options to specify and enable navigator or not
                    $Class: $JssorBulletNavigator$,                       //[Required] Class to create navigator instance
                    $ChanceToShow: 2,                               //[Required] 0 Never, 1 Mouse Over, 2 Always
                    $AutoCenter: 0,                                 //[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
                    $Lanes: 1,                                      //[Optional] Specify lanes to arrange items, default value is 1
                    $SpacingX: 10,                                   //[Optional] Horizontal space between each item in pixel, default value is 0
                    $SpacingY: 0,                                   //[Optional] Vertical space between each item in pixel, default value is 0
                    $Orientation: 1                                 //[Optional] The orientation of the navigator, 1 horizontal, 2 vertical, default value is 1
                },

            $CaptionSliderOptions: {
            $Class: $JssorCaptionSlider$,
            $CaptionTransitions: _CaptionTransitions,
            $PlayInMode: 1,
            $PlayOutMode: 3
        },

            };

            nestedSliders.push(new $JssorSlider$(containerId, nestedSliderOptions));
        });

        var options = {
            $AutoPlay: false,                                    //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
            $AutoPlaySteps: 1,                                  //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1
            $AutoPlayInterval: 2000,                            //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000
            $PauseOnHover: 0,                               //[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, default value is 1

            $ArrowKeyNavigation: true,                          //[Optional] Allows keyboard (arrow key) navigation or not, default value is false
            $SlideDuration: 300,                                //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
            $MinDragOffsetToSlide: 80,                          //[Optional] Minimum drag offset to trigger slide , default value is 20
            //$SlideWidth: 600,                                 //[Optional] Width of every slide in pixels, default value is width of 'slides' container
            //$SlideHeight: 150,                                //[Optional] Height of every slide in pixels, default value is height of 'slides' container
            $SlideSpacing: 3,                                   //[Optional] Space between each slide in pixels, default value is 0
            $DisplayPieces: 1,                                  //[Optional] Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), the default value is 1
            $ParkingPosition: 0,                                //[Optional] The offset position to park slide (this options applys only when slideshow disabled), default value is 0.
            $UISearchMode: 0,                                   //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc).
            $PlayOrientation: 1,                                //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, default value is 1
            $DragOrientation: 0,                                //[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),

            $ThumbnailNavigatorOptions: {
                $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
                $AutoCenter: 0,                                 //[Optional] Auto center thumbnail items in the thumbnail navigator container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 3
                $Lanes: 1,                                      //[Optional] Specify lanes to arrange thumbnails, default value is 1
                $SpacingX: 0,                                   //[Optional] Horizontal space between each thumbnail in pixel, default value is 0
                $SpacingY: 0,                                   //[Optional] Vertical space between each thumbnail in pixel, default value is 0
                $DisplayPieces: 6,                              //[Optional] Number of pieces to display, default value is 1
                $ParkingPosition: 0,                          //[Optional] The offset position to park thumbnail
                $Orientation: 2,                                //[Optional] Orientation to arrange thumbnails, 1 horizental, 2 vertical, default value is 1
                $DisableDrag: false                            //[Optional] Disable drag or not, default value is false
            }


    };

        var jssor_slider1 = new $JssorSlider$("slider1_container", options);


        function OnMainSliderPark(currentIndex, fromIndex) {
            $.each(nestedSliders, function (index, nestedSlider) {
                nestedSlider.$Pause();
            });

            setTimeout(function () {
                nestedSliders[currentIndex].$Play();
            }, 2000);
        }

...这是我的HTML

   <!-- Jssor Slider Begin -->
    <!-- You can move inline styles to css file or css block. -->
    <div id="slider1_container" style="position: relative; top: 0px; left: 0px; width: 960px; height: 385px; overflow: hidden; ">

        <!-- Loading Screen -->
        <div u="loading" style="position: absolute; top: 0px; left: 0px;">
            <div style="filter: alpha(opacity=70); opacity:0.7; position: absolute; display: block;
                background-color: #000; top: 0px; left: 0px;width: 100%;height:100%;">
            </div>
            <div style="position: absolute; display: block; background: url(../img/loading.gif) no-repeat center center;
                top: 0px; left: 0px;width: 100%;height:100%;">
            </div>
        </div>

        <!-- Slides Container -->
        <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 385px;
            overflow: hidden;">
            <div>
                <div id="sliderh1_container" class="sliderh1" style="position: relative; top: 0px; left: 0px; width: 960px;
                    height: 400px;">

                    <!-- Slides Container -->
                    <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 385px;
                        overflow: hidden;">
                        <div>
                        <a href="../virtualisation.html"><img u="image" src="../images/data-center-servers.jpg" /></a>
                                <div u="caption" t="transition_name1" style="position: absolute; top: 30px; left: 375px; width: 500px;height: 50px;">
                                <h1>Any HTML Content Here</h1>
                                </div>

                        </div>

                    </div>
                    <!-- Bullet Navigator Skin Begin -->
                    <!-- bullet navigator container -->
                    <div u="navigator" class="jssorb03" style="position: absolute; bottom: 120x; right: 10px;">
                        <!-- bullet navigator item prototype -->
                        <div u="prototype" style="position: absolute; width: 0px; height: 0px; text-align:center; line-height:21px; color:white; font-size:12px;"><NumberTemplate></NumberTemplate></div>
                    </div>
                    <!-- Bullet Navigator Skin End -->
                </div>
                <div u="thumb">

                    <div class="title_back"></div>
                    <div class="title">
                        Virtualisation
                        <img src="../images/virtualisation-icon.png" alt="Virtual Infrastructure" class="virtualicon">
                    </div>
                </div>
            </div>
            <div>
                <div id="sliderh2_container" class="sliderh2" style="position: relative; top: 0px; left: 0px; width: 960px;
                    height: 400px;">

                    <!-- Slides Container -->
                    <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 400px;
                        overflow: hidden;">
                        <div><img u="image" src="../images/clouds.jpg" />

                                <div u="caption" t="transition_name2" style="position: absolute; top: 30px; left: 375px; width: 500px;height: 50px;">
                                <h1>Any HTML Content Here</h1>
                                </div>

                        </div>

                    </div>
                    <!-- Bullet Navigator Skin Begin -->
                    <!-- bullet navigator container -->
                    <div u="navigator" class="jssorb03" style="position: absolute; bottom: 110px; right: 10px;">
                        <!-- bullet navigator item prototype -->
                        <div u="prototype" style="position: absolute; width: 0px; height: 0px; text-align:center; line-height:21px; color:white; font-size:12px;"><NumberTemplate></NumberTemplate></div>
                    </div>
                    <!-- Bullet Navigator Skin End -->
                </div>
                <div u="thumb">

                    <div class="title_back"></div>
                    <div class="title">
                        Cloud and Hosting
                        <img src="../images/cloud-icon.png" alt="Cloud and Hosting" class="cloudicon">
                    </div>
                </div>
            </div>
            <div>
                <div id="sliderh3_container" class="sliderh3" style="position: relative; top: 0px; left: 0px; width: 960px;
                    height: 400px;">
                                        <!-- Slides Container -->
                    <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 400px;
                        overflow: hidden;">
                        <div><img u="image" src="../images/collaboration.jpg" /></div>

                    </div>
                    <!-- Bullet Navigator Skin Begin -->
                    <!-- bullet navigator container -->
                    <div u="navigator" class="jssorb03" style="position: absolute; bottom: 110px; right: 10px;">
                        <!-- bullet navigator item prototype -->
                        <div u="prototype" style="position: absolute; width: 0px; height: 0px; text-align:center; line-height:21px; color:white; font-size:12px;"><NumberTemplate></NumberTemplate></div>
                    </div>
                    <!-- Bullet Navigator Skin End -->
                </div>
                <div u="thumb">

                    <div class="title_back"></div>
                    <div class="title">
                        Collaboration
                        <img src="../images/collaboration-icon.png" alt="Collaboration" class="collaborationicon">
                    </div>
                </div>
            </div>
            <div>
                <div id="sliderh4_container" class="sliderh4" style="position: relative; top: 0px; left: 0px; width: 960px;
                    height: 400px;">

                                        <!-- Slides Container -->
                    <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 400px;
                        overflow: hidden;">
                        <div><img u="image" src="../images/fingerprint.jpg" /></div>

                    </div>
                    <!-- Bullet Navigator Skin Begin -->
                    <!-- bullet navigator container -->
                    <div u="navigator" class="jssorb03" style="position: absolute; bottom: 110px; right: 10px;">
                        <!-- bullet navigator item prototype -->
                        <div u="prototype" style="position: absolute; width: 0px; height: 0px; text-align:center; line-height:21px; color:white; font-size:12px;"><NumberTemplate></NumberTemplate></div>
                    </div>
                    <!-- Bullet Navigator Skin End -->
                </div>
                <div u="thumb">

                    <div class="title_back"></div>
                    <div class="title">
                        Cyber Security
                        <img src="../images/security-icon.png" alt="Cyber Security" class="securityicon">
                    </div>
                </div>
            </div>
            <div>
                <div id="sliderh5_container" class="sliderh5" style="position: relative; top: 0px; left: 0px; width: 960px;
                    height: 400px;">

                                        <!-- Slides Container -->
                    <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 400px;
                        overflow: hidden;">
                        <div><img u="image" src="../images/fire.jpg" /></div>

                    </div>
                    <!-- Bullet Navigator Skin Begin -->
                    <!-- bullet navigator container -->
                    <div u="navigator" class="jssorb03" style="position: absolute; bottom: 110px; right: 10px;">
                        <!-- bullet navigator item prototype -->
                        <div u="prototype" style="position: absolute; width: 0px; height: 0px; text-align:center; line-height:21px; color:white; font-size:12px;"><NumberTemplate></NumberTemplate></div>
                    </div>
                    <!-- Bullet Navigator Skin End -->
                </div>
                <div u="thumb">

                    <div class="title_back"></div>
                    <div class="title">
                        Disaster Recovery
                        <img src="../images/dr-icon.png" alt="Disaster Recovery" class="dricon">
                    </div>
                </div>
            </div>
            <div>
                <div id="sliderh6_container" class="sliderh6" style="position: relative; top: 0px; left: 0px; width: 960px;
                    height: 400px;">

                    <!-- Slides Container -->
                    <div u="slides" style="cursor: default; position: absolute; left: 0px; top: 0px; width: 960px; height: 400px;
                        overflow: hidden;">
                        <div><img u="image" src="../images/network.jpg" /></div>

                    </div>
                    <!-- Bullet Navigator Skin Begin -->
                    <!-- bullet navigator container -->
                    <div u="navigator" class="jssorb03" style="position: absolute; bottom: 110px; right: 10px;">
                        <!-- bullet navigator item prototype -->
                        <div u="prototype" style="position: absolute; width: 0; height: 0px; text-align:center; line-height:21px; color:white; font-size:12px;"><NumberTemplate></NumberTemplate></div>
                    </div>
                    <!-- Bullet Navigator Skin End -->
                </div>
                <div u="thumb">

                    <div class="title_back"></div>
                    <div class="title">
                        Managed Networks
                        <img src="../images/networking-icon.png" alt="Managed Networks" class="networkingicon">
                    </div>
                </div>
            </div>

            <!-- Trigger -->
            <script>jssor_slider1('slider1_container');</script>

        </div>

        <!--Slider Navigation Buttons-->
        <!-- ThumbnailNavigator Skin Begin -->
        <div u="thumbnavigator" class="jssort12" style="cursor: pointer; position: absolute; width: 203px; height: 360px; left:114px; top: 0px;">

            <!-- Thumbnail Item Skin Begin -->

            <div u="slides" style="cursor: pointer;">
                <div u="prototype" class=p style="POSITION: absolute; WIDTH: 203px; HEIGHT: 60px; TOP: 0; LEFT: 0;">
                    <thumbnailtemplate style="WIDTH: 203px; HEIGHT: 60px; border: none; position: absolute; TOP: 0; LEFT: 0; "></thumbnailtemplate>
                </div>
            </div>
            <!-- Thumbnail Item Skin End -->
        </div>
        <!-- ThumbnailNavigator Skin End -->

        <a style="display: none" href="http://www.jssor.com">slideshow html</a>
    </div>
</div>

我的开发网站,可以在这里找到 http://goo.gl/WDkWD1

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

干得好,祝贺!

我注意到您在主滑块中管理了6个子滑块。 每个子滑块只有一张幻灯片。子滑块无法切换幻灯片,您知道在幻灯片更改时将启动字幕动画。

所以,实现目标的方法是, 制作一个包含6张幻灯片的滑块并将$ AutoPlay设置为false,将$ DragOrientation设置为0。