_onClick() { const navigator = util.findParent(this, 'ons-navigator'); if (navigator) { if (this.hasAttribute('animation')) { this.options.animation = this.getAttribute('animation'); } if (this.hasAttribute('animation-options')) { this.options.animationOptions = util.animationOptionsParse(this.getAttribute('animation-options')); } if (this.hasAttribute('on-transition-end')) { this.options.onTransitionEnd = window.eval('(' + this.getAttribute('on-transition-end') + ')'); } if (this.hasAttribute('refresh')) { this.options.refresh = this.getAttribute('refresh') === 'true'; } navigator.popPage(this.options); } }
/** * @method setActiveIndex * @signature setActiveIndex(index, [options]) * @param {Number} index * [en]The index that the carousel should be set to.[/en] * [ja]carousel要素のインデックスを指定します。[/ja] * @param {Object} [options] * [en]Parameter object.[/en] * [ja][/ja] * @param {Function} [options.callback] * [en]A function that will be called after the animation is finished.[/en] * [ja][/ja] * @param {String} [options.animation] * [en]If this attribute is set to `"none"` the transitions will not be animated.[/en] * [ja][/ja] * @param {Object} [options.animationOptions] * [en]An object that can be used to specify duration, delay and timing function of the animation.[/en] * [ja][/ja] * @description * [en]Specify the index of the `<ons-carousel-item>` to show.[/en] * [ja]表示するons-carousel-itemをindexで指定します。[/ja] * @return {Promise} * [en]Resolves to the carousel element.[/en] * [ja][/ja] */ setActiveIndex(index, options = {}) { if (options && typeof options != 'object') { throw new Error('options must be an object. You supplied ' + options); } options.animationOptions = util.extend( { duration: 0.3, timing: 'cubic-bezier(.1, .7, .1, 1)' }, options.animationOptions || {}, this.hasAttribute('animation-options') ? util.animationOptionsParse(this.getAttribute('animation-options')) : {} ); index = Math.max(0, Math.min(index, this.itemCount - 1)); const scroll = (this._offset || 0) + this._getCarouselItemSize() * index; const max = this._calculateMaxScroll(); this._scroll = Math.max(0, Math.min(max, scroll)); return this._scrollTo(this._scroll, options).then(() => { this._tryFirePostChangeEvent(); return this; }); }