/*! jCarousel - v0.3.0 - 2014-01-09 * http://sorgalla.com/jcarousel * Copyright (c) 2014 Jan Sorgalla; Licensed MIT */ (function($) { 'use strict'; $.jCarousel.plugin('jcarouselAutoscroll', { _options: { target: '+=1', interval: 3000, autostart: true }, _timer: null, _init: function () { this.onDestroy = $.proxy(function() { this._destroy(); this.carousel() .one('jcarousel:createend', $.proxy(this._create, this)); }, this); this.onAnimateEnd = $.proxy(this.start, this); }, _create: function() { this.carousel() .one('jcarousel:destroy', this.onDestroy); if (this.options('autostart')) { this.start(); } }, _destroy: function() { this.stop(); this.carousel() .off('jcarousel:destroy', this.onDestroy); }, start: function() { this.stop(); this.carousel() .one('jcarousel:animateend', this.onAnimateEnd); this._timer = setTimeout($.proxy(function() { this.carousel().jcarousel('scroll', this.options('target')); }, this), this.options('interval')); return this; }, stop: function() { if (this._timer) { this._timer = clearTimeout(this._timer); } this.carousel() .off('jcarousel:animateend', this.onAnimateEnd); return this; } }); }(jQuery));