-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy path3878-804089a07e445489906f.js.map
1 lines (1 loc) · 2.56 KB
/
3878-804089a07e445489906f.js.map
1
{"version":3,"file":"3878-804089a07e445489906f.js","mappings":"uIAAA,yuE","sources":["webpack://embla-carousel-docs/./src/components/Sandbox/Vanilla/SandboxFilesDist/Parallax/EmblaCarouselTweenParallax.ts"],"sourcesContent":["export default \"import { EmblaCarouselType, EmblaEventType } from 'embla-carousel'\\n\\nconst TWEEN_FACTOR_BASE = 0.2\\nlet tweenFactor = 0\\nlet tweenNodes: HTMLElement[] = []\\n\\nconst setTweenNodes = (emblaApi: EmblaCarouselType): void => {\\n tweenNodes = emblaApi.slideNodes().map((slideNode) => {\\n return slideNode.querySelector('.embla__parallax__layer') as HTMLElement\\n })\\n}\\n\\nconst setTweenFactor = (emblaApi: EmblaCarouselType): void => {\\n tweenFactor = TWEEN_FACTOR_BASE * emblaApi.scrollSnapList().length\\n}\\n\\nconst tweenParallax = (\\n emblaApi: EmblaCarouselType,\\n eventName?: EmblaEventType\\n): void => {\\n const engine = emblaApi.internalEngine()\\n const scrollProgress = emblaApi.scrollProgress()\\n const slidesInView = emblaApi.slidesInView()\\n const isScrollEvent = eventName === 'scroll'\\n\\n emblaApi.scrollSnapList().forEach((scrollSnap, snapIndex) => {\\n let diffToTarget = scrollSnap - scrollProgress\\n const slidesInSnap = engine.slideRegistry[snapIndex]\\n\\n slidesInSnap.forEach((slideIndex) => {\\n if (isScrollEvent && !slidesInView.includes(slideIndex)) return\\n\\n if (engine.options.loop) {\\n engine.slideLooper.loopPoints.forEach((loopItem) => {\\n const target = loopItem.target()\\n\\n if (slideIndex === loopItem.index && target !== 0) {\\n const sign = Math.sign(target)\\n\\n if (sign === -1) {\\n diffToTarget = scrollSnap - (1 + scrollProgress)\\n }\\n if (sign === 1) {\\n diffToTarget = scrollSnap + (1 - scrollProgress)\\n }\\n }\\n })\\n }\\n\\n const translate = diffToTarget * (-1 * tweenFactor) * 100\\n const tweenNode = tweenNodes[slideIndex]\\n tweenNode.style.transform = `translateX(${translate}%)`\\n })\\n })\\n}\\n\\nexport const setupTweenParallax = (\\n emblaApi: EmblaCarouselType\\n): (() => void) => {\\n setTweenNodes(emblaApi)\\n setTweenFactor(emblaApi)\\n tweenParallax(emblaApi)\\n\\n emblaApi\\n .on('reInit', setTweenNodes)\\n .on('reInit', setTweenFactor)\\n .on('reInit', tweenParallax)\\n .on('scroll', tweenParallax)\\n .on('slideFocus', tweenParallax)\\n\\n return (): void => {\\n tweenNodes.forEach((slide) => slide.removeAttribute('style'))\\n }\\n}\\n\";"],"names":[],"sourceRoot":""}