-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
1353-d3bbfb89b0203914df40.js
2 lines (2 loc) · 1.71 KB
/
1353-d3bbfb89b0203914df40.js
1
2
"use strict";(self.webpackChunkembla_carousel_docs=self.webpackChunkembla_carousel_docs||[]).push([[1353],{1353:function(n,e,o){o.r(e),e.default="import { EmblaCarouselType } from 'embla-carousel'\n\nexport const addDotBtnsAndClickHandlers = (\n emblaApi: EmblaCarouselType,\n dotsNode: HTMLElement,\n /*__NAV_AUTOPLAY_REPLACE_START__*/\n onButtonClick?: (emblaApi: EmblaCarouselType) => void\n /*__NAV_AUTOPLAY_REPLACE_END__*/\n): (() => void) => {\n let dotNodes: HTMLElement[] = []\n\n const addDotBtnsWithClickHandlers = (): void => {\n dotsNode.innerHTML = emblaApi\n .scrollSnapList()\n .map(() => '<button class=\"embla__dot\" type=\"button\"></button>')\n .join('')\n\n const scrollTo = (index: number): void => {\n emblaApi.scrollTo(index)\n /*__NAV_AUTOPLAY_REPLACE_START__*/\n if (onButtonClick) onButtonClick(emblaApi)\n /*__NAV_AUTOPLAY_REPLACE_END__*/\n }\n\n dotNodes = Array.from(dotsNode.querySelectorAll('.embla__dot'))\n dotNodes.forEach((dotNode, index) => {\n dotNode.addEventListener('click', () => scrollTo(index), false)\n })\n }\n\n const toggleDotBtnsActive = (): void => {\n const previous = emblaApi.previousScrollSnap()\n const selected = emblaApi.selectedScrollSnap()\n dotNodes[previous].classList.remove('embla__dot--selected')\n dotNodes[selected].classList.add('embla__dot--selected')\n }\n\n emblaApi\n .on('init', addDotBtnsWithClickHandlers)\n .on('reInit', addDotBtnsWithClickHandlers)\n .on('init', toggleDotBtnsActive)\n .on('reInit', toggleDotBtnsActive)\n .on('select', toggleDotBtnsActive)\n\n return (): void => {\n dotsNode.innerHTML = ''\n }\n}\n"}}]);
//# sourceMappingURL=1353-d3bbfb89b0203914df40.js.map