UNPKG

24.6 kBJavaScriptView Raw
1/*
2Copyright 2013-2015 ASIAL CORPORATION
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15
16*/
17
18import onsElements from '../ons/elements.js';
19import util from '../ons/util.js';
20import BaseElement from './base/base-element.js';
21import contentReady from '../ons/content-ready.js';
22import Swiper from '../ons/internal/swiper.js';
23
24/**
25 * @element ons-carousel
26 * @category carousel
27 * @description
28 * [en]
29 * Carousel component. A carousel can be used to display several items in the same space.
30 *
31 * The component supports displaying content both horizontally and vertically. The user can scroll through the items by dragging and it can also be controller programmatically.
32 * [/en]
33 * [ja][/ja]
34 * @codepen xbbzOQ
35 * @tutorial vanilla/Reference/carousel
36 * @seealso ons-carousel-item
37 * [en]`<ons-carousel-item>` component[/en]
38 * [ja]ons-carousel-itemコンポーネント[/ja]
39 * @example
40 * <ons-carousel style="width: 100%; height: 200px">
41 * <ons-carousel-item>
42 * ...
43 * </ons-carousel-item>
44 * <ons-carousel-item>
45 * ...
46 * </ons-carousel-item>
47 * </ons-carousel>
48 */
49export default class CarouselElement extends BaseElement {
50
51 /**
52 * @event postchange
53 * @description
54 * [en]Fired just after the current carousel item has changed.[/en]
55 * [ja]現在表示しているカルーセルの要素が変わった時に発火します。[/ja]
56 * @param {Object} event
57 * [en]Event object.[/en]
58 * [ja]イベントオブジェクトです。[/ja]
59 * @param {Object} event.carousel
60 * [en]Carousel object.[/en]
61 * [ja]イベントが発火したCarouselオブジェクトです。[/ja]
62 * @param {Number} event.activeIndex
63 * [en]Current active index.[/en]
64 * [ja]現在アクティブになっている要素のインデックス。[/ja]
65 * @param {Number} event.lastActiveIndex
66 * [en]Previous active index.[/en]
67 * [ja]以前アクティブだった要素のインデックス。[/ja]
68 */
69
70 /**
71 * @event prechange
72 * @description
73 * [en]Fired just before the current carousel item changes.[/en]
74 * [ja][/ja]
75 * @param {Object} event
76 * [en]Event object.[/en]
77 * [ja]イベントオブジェクトです。[/ja]
78 * @param {Object} event.carousel
79 * [en]Carousel object.[/en]
80 * [ja]イベントが発火したCarouselオブジェクトです。[/ja]
81 * @param {Number} event.activeIndex
82 * [en]Current active index.[/en]
83 * [ja]現在アクティブになっている要素のインデックス。[/ja]
84 * @param {Number} event.lastActiveIndex
85 * [en]Previous active index.[/en]
86 * [ja]以前アクティブだった要素のインデックス。[/ja]
87 */
88
89 /**
90 * @event refresh
91 * @description
92 * [en]Fired when the carousel has been refreshed.[/en]
93 * [ja]カルーセルが更新された時に発火します。[/ja]
94 * @param {Object} event
95 * [en]Event object.[/en]
96 * [ja]イベントオブジェクトです。[/ja]
97 * @param {Object} event.carousel
98 * [en]Carousel object.[/en]
99 * [ja]イベントが発火したCarouselオブジェクトです。[/ja]
100 */
101
102 /**
103 * @event overscroll
104 * @description
105 * [en]Fired when the carousel has been overscrolled.[/en]
106 * [ja]カルーセルがオーバースクロールした時に発火します。[/ja]
107 * @param {Object} event
108 * [en]Event object.[/en]
109 * [ja]イベントオブジェクトです。[/ja]
110 * @param {Object} event.carousel
111 * [en]Fired when the carousel has been refreshed.[/en]
112 * [ja]カルーセルが更新された時に発火します。[/ja]
113 * @param {Number} event.activeIndex
114 * [en]Current active index.[/en]
115 * [ja]現在アクティブになっている要素のインデックス。[/ja]
116 * @param {String} event.direction
117 * [en]Can be one of either "up", "down", "left" or "right".[/en]
118 * [ja]オーバースクロールされた方向が得られます。"up", "down", "left", "right"のいずれかの方向が渡されます。[/ja]
119 * @param {Function} event.waitToReturn
120 * [en]Takes a <code>Promise</code> object as an argument. The carousel will not scroll back until the promise has been resolved or rejected.[/en]
121 * [ja]この関数はPromiseオブジェクトを引数として受け取ります。渡したPromiseオブジェクトがresolveされるかrejectされるまで、カルーセルはスクロールバックしません。[/ja]
122 */
123
124 /**
125 * @event swipe
126 * @description
127 * [en]Fires when the carousel swipes.[/en]
128 * [ja][/ja]
129 * @param {Object} event
130 * [en]Event object.[/en]
131 * [ja]イベントオブジェクト。[/ja]
132 * @param {Number} event.index
133 * [en]Current index.[/en]
134 * [ja]現在アクティブになっているons-carouselのインデックスを返します。[/ja]
135 * @param {Object} event.options
136 * [en]Animation options object.[/en]
137 * [ja][/ja]
138 */
139
140 /**
141 * @attribute direction
142 * @type {String}
143 * @description
144 * [en]The direction of the carousel. Can be either "horizontal" or "vertical". Default is "horizontal".[/en]
145 * [ja]カルーセルの方向を指定します。"horizontal"か"vertical"を指定できます。"horizontal"がデフォルト値です。[/ja]
146 */
147
148 /**
149 * @attribute fullscreen
150 * @description
151 * [en]If this attribute is set the carousel will cover the whole screen.[/en]
152 * [ja]この属性があると、absoluteポジションを使ってカルーセルが自動的に画面いっぱいに広がります。[/ja]
153 */
154
155 /**
156 * @property fullscreen
157 * @type {Boolean}
158 * @description
159 * [en]If this property is set the carousel will cover the whole screen.[/en]
160 * [ja]この属性があると、absoluteポジションを使ってカルーセルが自動的に画面いっぱいに広がります。[/ja]
161 */
162
163 /**
164 * @attribute overscrollable
165 * @description
166 * [en]If this attribute is set the carousel will be scrollable over the edge. It will bounce back when released.[/en]
167 * [ja]この属性がある時、タッチやドラッグで端までスクロールした時に、バウンドするような効果が当たります。[/ja]
168 */
169
170 /**
171 * @attribute centered
172 * @description
173 * [en]If this attribute is set the carousel then the selected item will be in the center of the carousel instead of the beginning. Useful only when the items are smaller than the carousel. [/en]
174 * [ja]この属性がある時、選んでいるons-carousel-itemはカルーセルの真ん中へ行きます。項目がカルーセルよりも小さい場合にのみ、これは便利です。[/ja]
175 */
176
177 /**
178 * @attribute item-width
179 * @type {String}
180 * @description
181 * [en]ons-carousel-item's width. Only works when the direction is set to "horizontal".[/en]
182 * [ja]ons-carousel-itemの幅を指定します。この属性は、direction属性に"horizontal"を指定した時のみ有効になります。[/ja]
183 */
184
185 /**
186 * @attribute item-height
187 * @type {String}
188 * @description
189 * [en]ons-carousel-item's height. Only works when the direction is set to "vertical".[/en]
190 * [ja]ons-carousel-itemの高さを指定します。この属性は、direction属性に"vertical"を指定した時のみ有効になります。[/ja]
191 */
192
193 /**
194 * @attribute auto-scroll
195 * @description
196 * [en]If this attribute is set the carousel will be automatically scrolled to the closest item border when released.[/en]
197 * [ja]この属性がある時、一番近いcarousel-itemの境界まで自動的にスクロールするようになります。[/ja]
198 */
199
200 /**
201 * @attribute auto-scroll-ratio
202 * @type {Number}
203 * @description
204 * [en]A number between 0.0 and 1.0 that specifies how much the user must drag the carousel in order for it to auto scroll to the next item.[/en]
205 * [ja]0.0から1.0までの値を指定します。カルーセルの要素をどれぐらいの割合までドラッグすると次の要素に自動的にスクロールするかを指定します。[/ja]
206 */
207
208 /**
209 * @attribute swipeable
210 * @description
211 * [en]If this attribute is set the carousel can be scrolled by drag or swipe.[/en]
212 * [ja]この属性がある時、カルーセルをスワイプやドラッグで移動できるようになります。[/ja]
213 */
214
215 /**
216 * @attribute disabled
217 * @description
218 * [en]If this attribute is set the carousel is disabled.[/en]
219 * [ja]この属性がある時、dragやtouchやswipeを受け付けなくなります。[/ja]
220 */
221
222 /**
223 * @attribute initial-index
224 * @initonly
225 * @default 0
226 * @type {Number}
227 * @description
228 * [en]Specify the index of the ons-carousel-item to show initially. Default is 0. If active-index is set, initial-index is ignored.[/en]
229 * [ja]最初に表示するons-carousel-itemを0始まりのインデックスで指定します。デフォルト値は 0 です。[/ja]
230 */
231
232 /**
233 * @attribute auto-refresh
234 * @description
235 * [en]When this attribute is set the carousel will automatically refresh when the number of child nodes change.[/en]
236 * [ja]この属性がある時、子要素の数が変わるとカルーセルは自動的に更新されるようになります。[/ja]
237 */
238
239 /**
240 * @property autoRefresh
241 * @type {Boolean}
242 * @description
243 * [en]When this property is set the carousel will automatically refresh when the number of child nodes change.[/en]
244 * [ja]この属性がある時、子要素の数が変わるとカルーセルは自動的に更新されるようになります。[/ja]
245 */
246
247 /**
248 * @attribute animation
249 * @type {String}
250 * @description
251 * [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
252 * [ja][/ja]
253 */
254
255 /**
256 * @attribute animation-options
257 * @type {Expression}
258 * @description
259 * [en]Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.[/en]
260 * [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。例:{duration: 0.2, delay: 1, timing: 'ease-in'}[/ja]
261 */
262
263 constructor() {
264 super();
265
266 const {onConnected, onDisconnected} = util.defineListenerProperty(this, 'swipe');
267 this._connectOnSwipe = onConnected;
268 this._disconnectOnSwipe = onDisconnected;
269
270 contentReady(this, () => this._compile());
271 }
272
273 _compile() {
274 const target = this.children[0] && this.children[0].tagName !== 'ONS-CAROUSEL-ITEM' && this.children[0] || document.createElement('div');
275 if (!target.parentNode) {
276 while (this.firstChild) {
277 target.appendChild(this.firstChild);
278 }
279 this.appendChild(target);
280 }
281
282 !this.children[1] && this.appendChild(document.createElement('div'));
283
284 this.appendChild = this.appendChild.bind(target);
285 this.insertBefore = this.insertBefore.bind(target);
286 }
287
288 connectedCallback() {
289 if (!this._swiper) {
290 this._swiper = new Swiper({
291 getElement: () => this,
292 getInitialIndex: () => this.getAttribute('active-index') || this.getAttribute('initial-index'),
293 getAutoScrollRatio: () => this.autoScrollRatio,
294 isVertical: () => this.vertical,
295 isOverScrollable: () => this.overscrollable,
296 isCentered: () => this.centered,
297 isAutoScrollable: () => this.autoScroll,
298 itemSize: this.itemSize,
299 overScrollHook: this._onOverScroll.bind(this),
300 preChangeHook: this._onPreChange.bind(this),
301 postChangeHook: this._onPostChange.bind(this),
302 refreshHook: this._onRefresh.bind(this),
303 scrollHook: (index, options) => util.triggerElementEvent(this, 'swipe', { index, options })
304 });
305
306 contentReady(this, () => this._swiper.init({
307 swipeable: this.hasAttribute('swipeable'),
308 autoRefresh: this.hasAttribute('auto-refresh')
309 }));
310 }
311
312 this._connectOnSwipe();
313 }
314
315 disconnectedCallback() {
316 if (this._swiper && this._swiper.initialized) {
317 this._swiper.dispose();
318 this._swiper = null;
319 }
320
321 this._disconnectOnSwipe();
322 }
323
324 static get observedAttributes() {
325 return ['swipeable', 'auto-refresh', 'direction', 'item-height', 'item-width', 'active-index'];
326 }
327
328 attributeChangedCallback(name, last, current) {
329 if (!this._swiper) {
330 return;
331 }
332
333 switch (name) {
334 case 'swipeable':
335 this._swiper.updateSwipeable(this.hasAttribute('swipeable'));
336 break;
337 case 'auto-refresh':
338 this._swiper.updateAutoRefresh(this.hasAttribute('auto-refresh'));
339 break;
340 case 'item-height':
341 this.vertical && this._swiper.updateItemSize(this.itemSize);
342 break;
343 case 'item-width':
344 this.vertical || this._swiper.updateItemSize(this.itemSize);
345 break;
346 case 'direction':
347 this._swiper.refresh();
348 break;
349 case 'active-index':
350 if (this.getActiveIndex() !== this.activeIndex) {
351 this.setActiveIndex(this.activeIndex);
352 }
353 break;
354 }
355 }
356
357 _show() {
358 this._swiper.show();
359 }
360
361 _hide() {
362 this._swiper.hide();
363 }
364
365 _onOverScroll({ direction, killOverScroll }) {
366 let waitForAction = false;
367 util.triggerElementEvent(this, 'overscroll', {
368 carousel: this,
369 activeIndex: this.getActiveIndex(),
370 direction,
371 waitToReturn: promise => {
372 waitForAction = true;
373 promise.then(killOverScroll);
374 }
375 });
376
377 return waitForAction;
378 }
379
380 _onPreChange({ activeIndex, lastActiveIndex }) {
381 util.triggerElementEvent(this, 'prechange', { carousel: this, activeIndex, lastActiveIndex });
382 }
383
384 _onPostChange({ activeIndex, lastActiveIndex }) {
385 this.activeIndex = activeIndex;
386 util.triggerElementEvent(this, 'postchange', { carousel: this, activeIndex, lastActiveIndex });
387 }
388
389 _onRefresh() {
390 util.triggerElementEvent(this, 'refresh', { carousel: this });
391 }
392
393 /**
394 * @method setActiveIndex
395 * @signature setActiveIndex(index, [options])
396 * @param {Number} index
397 * [en]The index that the carousel should be set to.[/en]
398 * [ja]carousel要素のインデックスを指定します。[/ja]
399 * @param {Object} [options]
400 * [en]Parameter object.[/en]
401 * [ja][/ja]
402 * @param {Function} [options.callback]
403 * [en]A function that will be called after the animation is finished.[/en]
404 * [ja][/ja]
405 * @param {String} [options.animation]
406 * [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
407 * [ja][/ja]
408 * @param {Object} [options.animationOptions]
409 * [en]An object that can be used to specify duration, delay and timing function of the animation.[/en]
410 * [ja][/ja]
411 * @description
412 * [en]Specify the index of the `<ons-carousel-item>` to show.[/en]
413 * [ja]表示するons-carousel-itemをindexで指定します。[/ja]
414 * @return {Promise}
415 * [en]Resolves to the carousel element.[/en]
416 * [ja][/ja]
417 */
418 setActiveIndex(index, options = {}) {
419 options = {
420 animation: this.getAttribute('animation'),
421 animationOptions: this.animationOptions || { duration: .3, timing: 'cubic-bezier(.4, .7, .5, 1)' },
422 ...options
423 };
424
425 return this._swiper.setActiveIndex(index, options)
426 .then(() => {
427 options.callback instanceof Function && options.callback(this);
428 return Promise.resolve(this);
429 });
430 }
431
432 /**
433 * @method getActiveIndex
434 * @signature getActiveIndex()
435 * @return {Number}
436 * [en]The current carousel item index.[/en]
437 * [ja]現在表示しているカルーセル要素のインデックスが返されます。[/ja]
438 * @description
439 * [en]Returns the index of the currently visible `<ons-carousel-item>`.[/en]
440 * [ja]現在表示されているons-carousel-item要素のインデックスを返します。[/ja]
441 */
442 getActiveIndex() {
443 return this._swiper.getActiveIndex();
444 }
445
446 /**
447 * @method next
448 * @signature next([options])
449 * @param {Object} [options]
450 * [en]Parameter object.[/en]
451 * [ja][/ja]
452 * @param {Function} [options.callback]
453 * [en]A function that will be executed after the animation has finished.[/en]
454 * [ja][/ja]
455 * @param {String} [options.animation]
456 * [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
457 * [ja][/ja]
458 * @param {Object} [options.animationOptions]
459 * [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
460 * [ja][/ja]
461 * @return {Promise}
462 * [en]Resolves to the carousel element[/en]
463 * [ja][/ja]
464 * @description
465 * [en]Show next `<ons-carousel-item>`.[/en]
466 * [ja]次のons-carousel-itemを表示します。[/ja]
467 */
468 next(options) {
469 return this.setActiveIndex(this.getActiveIndex() + 1, options);
470 }
471
472 /**
473 * @method prev
474 * @signature prev([options])
475 * @param {Object} [options]
476 * [en]Parameter object.[/en]
477 * [ja][/ja]
478 * @param {Function} [options.callback]
479 * [en]A function that will be executed after the animation has finished.[/en]
480 * [ja][/ja]
481 * @param {String} [options.animation]
482 * [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
483 * [ja][/ja]
484 * @param {Object} [options.animationOptions]
485 * [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
486 * [ja][/ja]
487 * @return {Promise}
488 * [en]Resolves to the carousel element[/en]
489 * [ja][/ja]
490 * @description
491 * [en]Show previous `<ons-carousel-item>`.[/en]
492 * [ja]前のons-carousel-itemを表示します。[/ja]
493 */
494 prev(options) {
495 return this.setActiveIndex(this.getActiveIndex() - 1, options);
496 }
497
498 /**
499 * @method first
500 * @signature first()
501 * @param {Object} [options]
502 * [en]Parameter object.[/en]
503 * [ja][/ja]
504 * @param {Function} [options.callback]
505 * [en]A function that will be executed after the animation has finished.[/en]
506 * [ja][/ja]
507 * @param {String} [options.animation]
508 * [en]If this is set to `"none"`, the transitions will not be animated.[/en]
509 * [ja][/ja]
510 * @param {Object} [options.animationOptions]
511 * [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
512 * [ja][/ja]
513 * @return {Promise}
514 * [en]Resolves to the carousel element[/en]
515 * [ja][/ja]
516 * @description
517 * [en]Show first `<ons-carousel-item>`.[/en]
518 * [ja]最初のons-carousel-itemを表示します。[/ja]
519 */
520 first(options) {
521 return this.setActiveIndex(0, options);
522 }
523
524 /**
525 * @method last
526 * @signature last()
527 * @param {Object} [options]
528 * [en]Parameter object.[/en]
529 * [ja][/ja]
530 * @param {Function} [options.callback]
531 * [en]A function that will be executed after the animation has finished.[/en]
532 * [ja][/ja]
533 * @param {String} [options.animation]
534 * [en]If this attribute is set to `"none"` the transitions will not be animated.[/en]
535 * [ja][/ja]
536 * @param {Object} [options.animationOptions]
537 * [en]An object that can be used to specify the duration, delay and timing function of the animation.[/en]
538 * [ja][/ja]
539 * @return {Promise}
540 * [en]Resolves to the carousel element[/en]
541 * [ja]Resolves to the carousel element[/ja]
542 * @description
543 * [en]Show last ons-carousel item.[/en]
544 * [ja]最後のons-carousel-itemを表示します。[/ja]
545 */
546 last(options) {
547 this.setActiveIndex(Math.max(this.itemCount - 1, 0), options);
548 }
549
550 /**
551 * @method refresh
552 * @signature refresh()
553 * @description
554 * [en]Update the layout of the carousel. Used when adding `<ons-carousel-items>` dynamically or to automatically adjust the size.[/en]
555 * [ja]レイアウトや内部の状態を最新のものに更新します。ons-carousel-itemを動的に増やしたり、ons-carouselの大きさを動的に変える際に利用します。[/ja]
556 */
557 refresh() {
558 this._swiper.refresh();
559 }
560
561 /**
562 * @property itemCount
563 * @readonly
564 * @type {Number}
565 * @description
566 * [en]The number of carousel items.[/en]
567 * [ja]カルーセル要素の数です。[/ja]
568 */
569 get itemCount() {
570 return this._swiper.itemCount;
571 }
572
573 /**
574 * @property swipeable
575 * @type {Boolean}
576 * @description
577 * [en]true if the carousel is swipeable.[/en]
578 * [ja]swipeableであればtrueを返します。[/ja]
579 */
580
581 /**
582 * @property onSwipe
583 * @type {Function}
584 * @description
585 * [en]Hook called whenever the user slides the carousel. It gets a decimal index and an animationOptions object as arguments.[/en]
586 * [ja][/ja]
587 */
588
589 /**
590 * @property autoScroll
591 * @type {Boolean}
592 * @description
593 * [en]true if auto scroll is enabled.[/en]
594 * [ja]オートスクロールが有効であればtrueを返します。[/ja]
595 */
596
597 get vertical() {
598 return this.getAttribute('direction') === 'vertical';
599 }
600
601 get itemSize() {
602 const itemSizeAttr = (this.getAttribute(`item-${this.vertical ? 'height' : 'width'}`) || '').trim();
603 return itemSizeAttr.match(/^\d+(px|%)$/) ? itemSizeAttr : '100%';
604 }
605
606 /**
607 * @property autoScrollRatio
608 * @type {Number}
609 * @description
610 * [en]The current auto scroll ratio. [/en]
611 * [ja]現在のオートスクロールのratio値。[/ja]
612 */
613 get autoScrollRatio() {
614 return parseFloat(this.getAttribute('auto-scroll-ratio'));
615 }
616
617 set autoScrollRatio(ratio) {
618 this.setAttribute('auto-scroll-ratio', ratio);
619 }
620
621 /**
622 * @property disabled
623 * @type {Boolean}
624 * @description
625 * [en]Whether the carousel is disabled or not.[/en]
626 * [ja]無効化されている場合に`true`。[/ja]
627 */
628
629 /**
630 * @property overscrollable
631 * @type {Boolean}
632 * @description
633 * [en]Whether the carousel is overscrollable or not.[/en]
634 * [ja]overscrollできればtrueを返します。[/ja]
635 */
636
637 /**
638 * @property centered
639 * @type {Boolean}
640 * @description
641 * [en]Whether the carousel is centered or not.[/en]
642 * [ja]centered状態になっていればtrueを返します。[/ja]
643 */
644
645 static get events() {
646 return ['postchange', 'refresh', 'overscroll', 'prechange', 'swipe'];
647 }
648
649 /**
650 * @property animationOptions
651 * @type {Object}
652 * @description
653 * [en]Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.[/en]
654 * [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。例:{duration: 0.2, delay: 1, timing: 'ease-in'}[/ja]
655 */
656 get animationOptions() {
657 const attr = this.getAttribute('animation-options');
658 if (attr) {
659 return util.animationOptionsParse(attr);
660 } else {
661 return attr;
662 }
663 }
664
665 set animationOptions(value) {
666 if (value === undefined || value === null) {
667 this.removeAttribute('animation-options');
668 } else {
669 this.setAttribute('animation-options', JSON.stringify(value));
670 }
671 }
672
673 /**
674 * @attribute active-index
675 * @type {Number}
676 * @description
677 * [en]Specify the index of the carousel item that should be shown.[/en]
678 * [ja][/ja]
679 */
680
681 /**
682 * @property activeIndex
683 * @type {Number}
684 * @description
685 * [en]Specify the index of the carousel item that should be shown.[/en]
686 * [ja][/ja]
687 */
688 get activeIndex() {
689 return parseInt(this.getAttribute('active-index'));
690 }
691
692 set activeIndex(value) {
693 if (value !== undefined && value !== null) {
694 this.setAttribute('active-index', value);
695 }
696 }
697}
698
699util.defineBooleanProperties(CarouselElement, ['swipeable', 'disabled', 'overscrollable', 'auto-scroll', 'centered', 'fullscreen', 'auto-refresh']);
700
701onsElements.Carousel = CarouselElement;
702customElements.define('ons-carousel', CarouselElement);