-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
3975-e7e0bdcf76d6240b4427.js
2 lines (2 loc) · 1.19 KB
/
3975-e7e0bdcf76d6240b4427.js
1
2
"use strict";(self.webpackChunkembla_carousel_docs=self.webpackChunkembla_carousel_docs||[]).push([[3975],{6356:function(e,n,t){t.r(n),n.default="import React, { useCallback, useEffect, useState } from 'react';\n\nexport const useSelectedSnapDisplay = (emblaApi) => {\n const [selectedSnap, setSelectedSnap] = useState(0);\n const [snapCount, setSnapCount] = useState(0);\n \n const updateScrollSnapState = useCallback((emblaApi) => {\n setSnapCount(emblaApi.scrollSnapList().length);\n setSelectedSnap(emblaApi.selectedScrollSnap());\n }, []);\n \n useEffect(() => {\n if (!emblaApi)\n return;\n \n updateScrollSnapState(emblaApi);\n emblaApi.on('select', updateScrollSnapState);\n emblaApi.on('reInit', updateScrollSnapState);\n }, [emblaApi, updateScrollSnapState]);\n \n return {\n selectedSnap,\n snapCount\n };\n};\n\nexport const SelectedSnapDisplay = (props) => {\n const { selectedSnap, snapCount } = props;\n \n return (<div className=\"embla__selected-snap-display\">\n {selectedSnap + 1} / {snapCount}\n </div>);\n};\n"}}]);
//# sourceMappingURL=3975-e7e0bdcf76d6240b4427.js.map