swipebox自动转换到下一张幻灯片

时间:2016-02-16 13:54:28

标签: javascript jquery slider slideshow

这不仅仅是一个问题,而是一个问题,但我希望其他人认为这有用。

基本上我需要制作名为' Swipebox'的灯箱滑块。自动转换到下一张幻灯片,我在网上寻求帮助,但一无所获。

要将此功能添加到插件中,我添加了以下代码:

setInterval(function(){

     $this.getNext();  // Auto transitions each slide

}, 5000);

此JS的文件名为' jquery.swipebox.js'。这是您要放置前面提到的代码的代码:

/**
         * Navigation events : go to next slide, go to prevous slide and close
         */
        actions : function () {
            var $this = this,
                action = 'touchend click'; // Just detect for both event types to allow for multi-input

            if ( elements.length < 2 ) {

                $( '#swipebox-bottom-bar' ).hide();

                if ( undefined === elements[ 1 ] ) {
                    $( '#swipebox-top-bar' ).hide();
                }

            } else {
                $( '#swipebox-prev' ).bind( action, function( event ) {
                    event.preventDefault();
                    event.stopPropagation();
                    $this.getPrev();
                    $this.setTimeout();
                } );

                $( '#swipebox-next' ).bind( action, function( event ) {
                    event.preventDefault();
                    event.stopPropagation();
                    $this.getNext();
                    $this.setTimeout();
                } );
            }

            $( '#swipebox-close' ).bind( action, function() {
                $this.closeSlide();
            } );


// THIS IS THE NEW CODE ADDED:

            setInterval(function(){

                $this.getNext();  // Auto transitions each slide

            }, 5000);
        },

此功能约为550行。

此外,要使幻灯片循环回来,您需要更改名为&#39; loopAtEnd&#39;从FALSE到TRUE。它位于文档的顶部。

loopAtEnd: true,

希望这有助于:)

0 个答案:

没有答案
相关问题