-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy path3165-08b551db385c3e4eb000.js
2 lines (2 loc) · 1.96 KB
/
3165-08b551db385c3e4eb000.js
1
2
"use strict";(self.webpackChunkembla_carousel_docs=self.webpackChunkembla_carousel_docs||[]).push([[3165],{3165:function(n,t,o){o.r(t),t.default="\nexport const addPlayBtnListeners = (emblaApi, playBtn) => {\n const togglePlayBtnState = (emblaApi) => {\n const autoScroll = emblaApi?.plugins()?.autoScroll;\n if (!autoScroll)\n return;\n \n const buttonText = autoScroll.isPlaying() ? 'Start' : 'Stop';\n playBtn.innerHTML = buttonText;\n };\n \n const onPlayBtnClick = () => {\n const autoScroll = emblaApi?.plugins()?.autoScroll;\n if (!autoScroll)\n return;\n \n const playOrStop = autoScroll.isPlaying()\n ? autoScroll.stop\n : autoScroll.play;\n playOrStop();\n };\n \n playBtn.addEventListener('click', onPlayBtnClick);\n emblaApi\n .on('autoScroll:play', togglePlayBtnState)\n .on('autoScroll:stop', togglePlayBtnState)\n .on('reInit', togglePlayBtnState);\n \n return () => {\n playBtn.removeEventListener('click', onPlayBtnClick);\n emblaApi\n .off('autoScroll:play', togglePlayBtnState)\n .off('autoScroll:stop', togglePlayBtnState)\n .off('reInit', togglePlayBtnState);\n };\n};\n\nexport const addNavBtnListeners = (emblaApi, ...navButtons) => {\n const onNavClick = () => {\n const autoScroll = emblaApi?.plugins()?.autoScroll;\n if (!autoScroll)\n return;\n \n const resetOrStop = autoScroll.options.stopOnInteraction === false\n ? autoScroll.reset\n : autoScroll.stop;\n \n resetOrStop();\n };\n \n navButtons.forEach((navButton) => navButton.addEventListener('click', onNavClick, true));\n \n return () => {\n navButtons.forEach((navButton) => navButton.removeEventListener('click', onNavClick, true));\n };\n};\n"}}]);
//# sourceMappingURL=3165-08b551db385c3e4eb000.js.map