UNPKG

igniteui-webcomponents

Version:

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.

84 lines 3.43 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { consume } from '@lit/context'; import { html, LitElement } from 'lit'; import { property } from 'lit/decorators.js'; import { EaseInOut } from '../../animations/easings.js'; import { addAnimationController } from '../../animations/player.js'; import { carouselContext } from '../common/context.js'; import { addInternalsController } from '../common/controllers/internals.js'; import { registerComponent } from '../common/definitions/register.js'; import { formatString } from '../common/util.js'; import { animations } from './animations.js'; import { styles } from './themes/carousel-slide.base.css.js'; let nextId = 1; class IgcCarouselSlideComponent extends LitElement { constructor() { super(...arguments); this._internals = addInternalsController(this, { initialARIA: { role: 'tabpanel', ariaRoleDescription: 'slide', }, }); this._player = addAnimationController(this); this.active = false; this.previous = false; } static register() { registerComponent(IgcCarouselSlideComponent); } get _index() { return this._carousel ? this._carousel.slides.indexOf(this) : 0; } get _total() { return this._carousel ? this._carousel.slides.length : 0; } get _animation() { const animation = this._carousel?.animationType ?? 'slide'; if (animation === 'slide') { return this._carousel?.vertical ? 'slideVer' : 'slideHor'; } return animation; } get _labelFormat() { return this._carousel ? this._carousel.slidesLabelFormat : ''; } async toggleAnimation(type, direction = 'normal') { const animation = animations.get(this._animation).get(type); return await this._player.playExclusive(animation({ duration: 320, easing: EaseInOut.Quad, direction, })); } willUpdate() { this._internals.setARIA({ ariaLabel: formatString(this._labelFormat, this._index + 1, this._total), }); } connectedCallback() { super.connectedCallback(); this.id = this.id || `igc-carousel-slide-${nextId++}`; } render() { return html `<slot></slot>`; } } IgcCarouselSlideComponent.styles = styles; IgcCarouselSlideComponent.tagName = 'igc-carousel-slide'; export default IgcCarouselSlideComponent; __decorate([ consume({ context: carouselContext, subscribe: true }) ], IgcCarouselSlideComponent.prototype, "_carousel", void 0); __decorate([ property({ type: Boolean, reflect: true }) ], IgcCarouselSlideComponent.prototype, "active", void 0); __decorate([ property({ type: Boolean, reflect: true }) ], IgcCarouselSlideComponent.prototype, "previous", void 0); //# sourceMappingURL=carousel-slide.js.map