-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy path1618-7b4a00f39bd6ebb745b3.js
2 lines (2 loc) · 1.93 KB
/
1618-7b4a00f39bd6ebb745b3.js
1
2
"use strict";(self.webpackChunkembla_carousel_docs=self.webpackChunkembla_carousel_docs||[]).push([[1618],{1618:function(e,n,t){t.r(n),n.default="import EmblaCarousel, { EmblaOptionsType } from 'embla-carousel'\nimport {\n setupInfiniteScroll,\n mockApiCall,\n SLIDE_TEMPLATE,\n createHTMLFromString\n} from './EmblaCarouselInfiniteScroll'\nimport { addPrevNextBtnsClickHandlers } from '../EmblaCarouselArrowButtons'\nimport '../css/base.css'\nimport '../css/sandbox.css'\nimport '../css/embla.css'\n\nconst OPTIONS: EmblaOptionsType = {}\n\nconst emblaNode = <HTMLElement>document.querySelector('.embla')\nconst viewportNode = <HTMLElement>emblaNode.querySelector('.embla__viewport')\nconst prevBtn = <HTMLElement>emblaNode.querySelector('.embla__button--prev')\nconst nextBtn = <HTMLElement>emblaNode.querySelector('.embla__button--next')\n\nconst emblaApi = EmblaCarousel(viewportNode, OPTIONS)\n\nconst removePrevNextBtnsClickHandlers = addPrevNextBtnsClickHandlers(\n emblaApi,\n prevBtn,\n nextBtn\n)\n\nconst onResize = () => emblaApi.reInit()\nconst startInfiniteScroll = setupInfiniteScroll(\n emblaApi,\n (loadMore, endInfiniteScroll, slideCount) => {\n mockApiCall(1000, 2000, () => {\n if (slideCount === 20) return endInfiniteScroll()\n\n const fiveNewSlideNodes = Array.from(Array(5).keys())\n const slideNodesToAdd = fiveNewSlideNodes\n .map(() => SLIDE_TEMPLATE)\n .map((template, index) => {\n const slideNumber = slideCount + index + 1\n return template.replace('__SLIDE_NUMBER__', slideNumber.toString())\n })\n .map(createHTMLFromString)\n\n loadMore(slideNodesToAdd)\n })\n }\n)\n\nemblaApi\n .on('init', startInfiniteScroll)\n .on('destroy', () => {\n window.removeEventListener('resize', onResize)\n })\n .on('destroy', removePrevNextBtnsClickHandlers)\n\nwindow.addEventListener('resize', onResize)\n"}}]);
//# sourceMappingURL=1618-7b4a00f39bd6ebb745b3.js.map