UNPKG

@exadel/esl

Version:

Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components

50 lines (49 loc) 2.42 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 { ExportNs } from '../../../esl-utils/environment/export-ns'; import { attr, listen } from '../../../esl-utils/decorators'; import { ESLCarouselAutoplayStateMixin } from './esl-carousel.autoplay.state.mixin'; /** * External autoplay control mixin. * Hosts on a control element and toggles autoplay state for the target carousel. */ let ESLCarouselAutoplayControlMixin = class ESLCarouselAutoplayControlMixin extends ESLCarouselAutoplayStateMixin { disconnectedCallback() { super.disconnectedCallback(); this.$$attr('aria-controls', null); this.$$attr('aria-pressed', null); } /** Synchronize control state markers and a11y state */ syncState() { super.syncState(); const { autoplay } = this; const pressed = this.behaviour === 'pause' ? !!(autoplay === null || autoplay === void 0 ? void 0 : autoplay.paused) : !!(autoplay === null || autoplay === void 0 ? void 0 : autoplay.enabled); this.$$attr('aria-controls', this.targetID); this.$$attr('aria-pressed', String(pressed)); } /** Handles host click and toggles autoplay using configured behaviour */ _onClick(e) { const { autoplay } = this; if (!autoplay) return; autoplay.toggle(this.behaviour); e.preventDefault(); } }; ESLCarouselAutoplayControlMixin.is = 'esl-carousel-autoplay-control'; __decorate([ attr({ name: ESLCarouselAutoplayControlMixin.is, defaultValue: 'stop' }) ], ESLCarouselAutoplayControlMixin.prototype, "behaviour", void 0); __decorate([ listen('click') ], ESLCarouselAutoplayControlMixin.prototype, "_onClick", null); ESLCarouselAutoplayControlMixin = __decorate([ ExportNs('Carousel.AutoplayControl') ], ESLCarouselAutoplayControlMixin); export { ESLCarouselAutoplayControlMixin };