简体   繁体   English

jquery超大了stop_loop重定向?

[英]jquery supersized stop_loop redirect?

i have four images slides and i want to redirect once finish sliding. 我有四个图像幻灯片,我想重新定位一次完成滑动。 how? 怎么样?

sample code: 示例代码:

jQuery(function($){                     
    $.supersized({                      
        // Functionality
        slideshow : 1,  // Slideshow on/off
        autoplay : 1,    // Slideshow starts playing automatically
        start_slide : 1, // Start slide (0 is random)
        stop_loop : [
                    if (data)
                    {
                        window.location = "http://www.google.com/";
                    }
                    ], // Pauses slideshow on last slide
        random: 0,     // Randomize slide order (Ignores start slide)
        slide_interval : 9000,  // Length between transitions
        transition : 6, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 
                            // 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 
                            // 7-Carousel Left
        transition_speed : 2000, // Speed of transition
    });
});

According to the Supersized documentation , the stop_loop settings is a boolean to say whether to "pause" once the last slide is reached, it doesn't take a callback to be run at the end of the loop and the way you included the code there in your question is a syntax error. 根据Supersized文档stop_loop设置是一个布尔值,表示一旦到达最后一张幻灯片是否“暂停”,它不会在循环结束时运行回调以及在那里包含代码的方式在您的问题中是语法错误。

I don't see anything in the doco about a way to receive a notification when the slideshow reaches its end, so the only thing that comes to mind (other than altering the Supersized source) is a setTimeout() : 我在幻灯片中没有看到任何关于在幻灯片结束时收到通知的方式,因此唯一想到的(除了更改超级源代码之外)是setTimeout()

jQuery(function($){
    var interval = 9000,
        speed = 2000,
        slideArray = [];  // add your slides to this array

    $.supersized({
        slideshow : 1,
        autoplay : 1,
        start_slide : 1,
        stop_loop : true, // Pauses slideshow on last slide
        random: 0,
        slides : slideArray,
        slide_interval : interval,
        transition : 6,
        transition_speed : speed,
    });

    setTimeout(function() {
        if (data) 
           window.location = "http://www.google.com/";
    }, (interval + speed) * slideArray.length);    
});

That is, figure out how long the whole slideshow should take and run your redirection code after that amount of time. 也就是说,弄清楚整个幻灯片应该花多长时间,并在这段时间后运行重定向代码。 Your code didn't specify any slides, but I've added an array variable where they could be specified and used that array's length in calculating the delay. 您的代码没有指定任何幻灯片,但我添加了一个数组变量,可以指定它们并在计算延迟时使用该数组的长度。

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

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