简体   繁体   English

所有幻灯片的JSSOR字幕会同时触发

[英]JSSOR Captions trigger at the same time for all slides

I have constructed the following code for a Slideshow with Captions using JSSOR. 我使用JSSOR为带有字幕的幻灯片构建了以下代码。

However for some reason all of the captions trigger at the same time. 但是,由于某些原因,所有字幕都会同时触发。

What I would like to happen is every time I click on a slide then the relevant captions trigger. 我想发生的事情是,每当我单击幻灯片时,就会触发相关的字幕。

To explain what in more detail. 来详细解释一下。 If I click on slide one, then quickly onto slide 2 I see the end of the slide 2 caption transition. 如果单击幻灯片1,然后快速转到幻灯片2,我会看到幻灯片2字幕转换的结尾。 But it would appear that it only triggers once on page load. 但似乎它只触发一次页面加载。 I would like it to run when the slide is selected. 我希望它在选择幻灯片后运行。

Here is my JSSOR code 这是我的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);
        }

...and this is my HTML ...这是我的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>

My development site, can be found here http://goo.gl/WDkWD1 我的开发站点,可以在这里找到http://goo.gl/WDkWD1

Any help greatly appreciated. 任何帮助,不胜感激。

Nice work, congratulations! 做得好,恭喜!

I noticed that you manage 6 child sliders in a main slider. 我注意到您在一个主滑块中管理6个子滑块。 And each child slider has only 1 slide. 每个子滑块只有1个幻灯片。 There is no chance for child slider to switch slide, you'd know that caption animation will start when slide change. 子滑块没有机会切换幻灯片,您知道字幕动画将在更换幻灯片时开始。

So, the way to reach your goal is to, Make a single slider with 6 slides and set $AutoPlay to false, set $DragOrientation to 0. 因此,达到目标的方法是,制作一个包含6张幻灯片的单个滑块,并将$ AutoPlay设置为false,将$ DragOrientation设置为0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM