jsor / jcarousel

Riding carousels with jQuery.
https://sorgalla.com/jcarousel/
MIT License
1.99k stars 734 forks source link

Can't add autoscroll in jcarousel #788

Closed chopenko7 closed 8 years ago

chopenko7 commented 8 years ago

Please, help me! I would like to add a auto to the carousel does anybody know how its done. Any one know how its done

Thanks

`/global window, jQuery / (function($) { // Default configuration properties. var defaults = { vertical: false, rtl: false, start: 1, offset: 1, size: null, scroll: 1, visible: null, animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, setupCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, animationStepCallback: null, buttonNextHTML: '

', buttonPrevHTML: '
', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null, itemFallbackDimension: null }, windowLoaded = false;

$(window).bind('load.jcarousel', function() { windowLoaded = true; });

/* * Starts autoscrolling. * @method auto * @return undefined * @param s {Number} Seconds to periodically autoscroll the content. */ startAuto: function(s) { if (s !== undefined) { this.options.auto = s; }

        if (this.options.auto === 0) {
            return this.stopAuto();
        }

        if (this.timer !== null) {
            return;
        }

        this.autoStopped = false;

        var self = this;
        this.timer = window.setTimeout(function() { self.next(); }, this.options.auto * 1000);
    },

    /**
     * Stops autoscrolling.
     *
     * @method stopAuto
     * @return undefined
     */
    stopAuto: function() {
        this.pauseAuto();
        this.autoStopped = true;
    },`

part of code

snake-345 commented 8 years ago

You may use autoscroll plugin. Example: https://jsfiddle.net/ssw5w8ue/