embla-carousel
Advanced tools
Comparing version 6.2.0 to 7.0.0-rc01
@@ -5,3 +5,3 @@ import { AnimationType } from './Animation'; | ||
import { DragTrackerType } from './DragTracker'; | ||
import { EventEmitterType } from './EventEmitter'; | ||
import { EventHandlerType } from './EventHandler'; | ||
import { AxisType } from './Axis'; | ||
@@ -12,2 +12,3 @@ import { ScrollBodyType } from './ScrollBody'; | ||
import { Vector1DType } from './Vector1d'; | ||
import { PercentOfViewType } from './PercentOfView'; | ||
export declare type DragHandlerType = { | ||
@@ -19,2 +20,2 @@ addActivationEvents: () => void; | ||
}; | ||
export declare function DragHandler(axis: AxisType, direction: DirectionType, rootNode: HTMLElement, target: Vector1DType, dragFree: boolean, dragTracker: DragTrackerType, location: Vector1DType, animation: AnimationType, scrollTo: ScrollToType, scrollBody: ScrollBodyType, scrollTarget: ScrollTargetType, index: CounterType, events: EventEmitterType, loop: boolean, skipSnaps: boolean): DragHandlerType; | ||
export declare function DragHandler(axis: AxisType, direction: DirectionType, rootNode: HTMLElement, target: Vector1DType, dragTracker: DragTrackerType, location: Vector1DType, animation: AnimationType, scrollTo: ScrollToType, scrollBody: ScrollBodyType, scrollTarget: ScrollTargetType, index: CounterType, eventHandler: EventHandlerType, percentOfView: PercentOfViewType, loop: boolean, dragFree: boolean, skipSnaps: boolean): DragHandlerType; |
import { AxisOptionType, AxisType } from './Axis'; | ||
import { PxToPercentType } from './PxToPercent'; | ||
export declare type PointerEventType = TouchEvent | MouseEvent; | ||
@@ -11,2 +10,2 @@ export declare type DragTrackerType = { | ||
}; | ||
export declare function DragTracker(axis: AxisType, pxToPercent: PxToPercentType): DragTrackerType; | ||
export declare function DragTracker(axis: AxisType): DragTrackerType; |
@@ -6,7 +6,7 @@ import { AnimationType } from './Animation'; | ||
import { DragHandlerType } from './DragHandler'; | ||
import { EventEmitterType } from './EventEmitter'; | ||
import { EventHandlerType } from './EventHandler'; | ||
import { EventStoreType } from './EventStore'; | ||
import { LimitType } from './Limit'; | ||
import { OptionsType } from './Options'; | ||
import { PxToPercentType } from './PxToPercent'; | ||
import { PercentOfViewType } from './PercentOfView'; | ||
import { ScrollBodyType } from './ScrollBody'; | ||
@@ -20,5 +20,6 @@ import { ScrollBoundsType } from './ScrollBounds'; | ||
import { SlidesInViewType } from './SlidesInView'; | ||
import { SlidesToScrollType } from './SlidesToScroll'; | ||
import { TranslateType } from './Translate'; | ||
import { Vector1DType } from './Vector1d'; | ||
export declare type Engine = { | ||
export declare type EngineType = { | ||
axis: AxisType; | ||
@@ -35,3 +36,3 @@ direction: DirectionType; | ||
options: OptionsType; | ||
pxToPercent: PxToPercentType; | ||
percentOfView: PercentOfViewType; | ||
scrollBody: ScrollBodyType; | ||
@@ -42,2 +43,3 @@ dragHandler: DragHandlerType; | ||
slidesInView: SlidesInViewType; | ||
slidesToScroll: SlidesToScrollType; | ||
target: Vector1DType; | ||
@@ -52,2 +54,2 @@ translate: TranslateType; | ||
}; | ||
export declare function Engine(root: HTMLElement, container: HTMLElement, slides: HTMLElement[], options: OptionsType, events: EventEmitterType): Engine; | ||
export declare function Engine(root: HTMLElement, container: HTMLElement, slides: HTMLElement[], options: OptionsType, eventHandler: EventHandlerType): EngineType; |
@@ -1,4 +0,6 @@ | ||
import { Engine } from './Engine'; | ||
import { EventEmitterType } from './EventEmitter'; | ||
import { EngineType } from './Engine'; | ||
import { EventHandlerType } from './EventHandler'; | ||
import { EmblaOptionsType } from './Options'; | ||
import { OptionsHandler } from './OptionsHandler'; | ||
import { EmblaPluginsType, EmblaPluginType } from './Plugins'; | ||
export declare type EmblaNodesType = { | ||
@@ -9,12 +11,2 @@ root: HTMLElement; | ||
}; | ||
declare type EmblaPluginOptionsType = { | ||
[key: string]: unknown; | ||
}; | ||
export declare type EmblaPluginType<OptionsType extends EmblaPluginOptionsType = EmblaPluginOptionsType> = { | ||
name: string; | ||
options: OptionsType; | ||
init: (embla: EmblaCarouselType) => void; | ||
destroy: () => void; | ||
[key: string]: unknown; | ||
}; | ||
export declare type EmblaCarouselType = { | ||
@@ -25,6 +17,7 @@ canScrollNext: () => boolean; | ||
containerNode: () => HTMLElement; | ||
internalEngine: () => Engine; | ||
internalEngine: () => EngineType; | ||
destroy: () => void; | ||
off: EventEmitterType['off']; | ||
on: EventEmitterType['on']; | ||
off: EventHandlerType['off']; | ||
on: EventHandlerType['on']; | ||
plugins: () => EmblaPluginsType; | ||
previousScrollSnap: () => number; | ||
@@ -46,3 +39,4 @@ reInit: (options?: EmblaOptionsType, plugins?: EmblaPluginType[]) => void; | ||
var globalOptions: Partial<import("./Options").OptionsType> | undefined; | ||
var optionsHandler: typeof OptionsHandler; | ||
} | ||
export default EmblaCarousel; |
import { AlignmentOptionType } from './Alignment'; | ||
import { AxisOptionType } from './Axis'; | ||
import { SlidesToScrollOptionType } from './SlidesToScroll'; | ||
import { DirectionOptionType } from './Direction'; | ||
import { ScrollContainOptionType } from './ScrollContain'; | ||
export declare type OptionsType = { | ||
export declare type LooseOptionsType = { | ||
[key: string]: unknown; | ||
}; | ||
export declare type CreateOptionsType<Type extends LooseOptionsType> = Type & { | ||
active: boolean; | ||
breakpoints: { | ||
[key: string]: Omit<Partial<CreateOptionsType<Type>>, 'breakpoints'>; | ||
}; | ||
}; | ||
export declare type OptionsType = CreateOptionsType<{ | ||
align: AlignmentOptionType; | ||
@@ -10,2 +20,3 @@ axis: AxisOptionType; | ||
direction: DirectionOptionType; | ||
slidesToScroll: SlidesToScrollOptionType; | ||
dragFree: boolean; | ||
@@ -16,7 +27,6 @@ draggable: boolean; | ||
skipSnaps: boolean; | ||
slidesToScroll: number; | ||
speed: number; | ||
startIndex: number; | ||
}; | ||
}>; | ||
export declare const defaultOptions: OptionsType; | ||
export declare type EmblaOptionsType = Partial<OptionsType>; |
import { LimitType } from './Limit'; | ||
import { ScrollBodyType } from './ScrollBody'; | ||
import { Vector1DType } from './Vector1d'; | ||
import { PercentOfViewType } from './PercentOfView'; | ||
export declare type ScrollBoundsType = { | ||
@@ -8,2 +9,2 @@ constrain: (pointerDown: boolean) => void; | ||
}; | ||
export declare function ScrollBounds(limit: LimitType, location: Vector1DType, target: Vector1DType, scrollBody: ScrollBodyType): ScrollBoundsType; | ||
export declare function ScrollBounds(limit: LimitType, location: Vector1DType, target: Vector1DType, scrollBody: ScrollBodyType, percentOfView: PercentOfViewType): ScrollBoundsType; |
@@ -5,2 +5,2 @@ export declare type ScrollContainOptionType = '' | 'trimSnaps' | 'keepSnaps'; | ||
}; | ||
export declare function ScrollContain(viewSize: number, contentSize: number, snaps: number[], snapsAligned: number[], containScroll: ScrollContainOptionType): ScrollContainType; | ||
export declare function ScrollContain(viewSize: number, contentSize: number, snapsAligned: number[], containScroll: ScrollContainOptionType): ScrollContainType; |
import { LimitType } from './Limit'; | ||
import { PxToPercentType } from './PxToPercent'; | ||
import { Vector1DType } from './Vector1d'; | ||
@@ -7,2 +6,2 @@ export declare type ScrollLooperType = { | ||
}; | ||
export declare function ScrollLooper(contentSize: number, pxToPercent: PxToPercentType, limit: LimitType, location: Vector1DType, vectors: Vector1DType[]): ScrollLooperType; | ||
export declare function ScrollLooper(contentSize: number, limit: LimitType, location: Vector1DType, vectors: Vector1DType[]): ScrollLooperType; |
import { AnimationType } from './Animation'; | ||
import { CounterType } from './Counter'; | ||
import { EventEmitterType } from './EventEmitter'; | ||
import { EventHandlerType } from './EventHandler'; | ||
import { ScrollTargetType } from './ScrollTarget'; | ||
@@ -10,2 +10,2 @@ import { Vector1DType } from './Vector1d'; | ||
}; | ||
export declare function ScrollTo(animation: AnimationType, indexCurrent: CounterType, indexPrevious: CounterType, scrollTarget: ScrollTargetType, targetVector: Vector1DType, events: EventEmitterType): ScrollToType; | ||
export declare function ScrollTo(animation: AnimationType, indexCurrent: CounterType, indexPrevious: CounterType, scrollTarget: ScrollTargetType, targetVector: Vector1DType, eventHandler: EventHandlerType): ScrollToType; |
import { AxisType } from './Axis'; | ||
import { SlidesInViewType } from './SlidesInView'; | ||
import { Vector1DType } from './Vector1d'; | ||
import { TranslateType } from './Translate'; | ||
import { DirectionType } from './Direction'; | ||
declare type LoopPointType = { | ||
point: number; | ||
location: number; | ||
index: number; | ||
getTarget: () => number; | ||
translate: TranslateType; | ||
location: Vector1DType; | ||
target: () => Vector1DType; | ||
}; | ||
@@ -16,3 +18,3 @@ export declare type SlideLooperType = { | ||
}; | ||
export declare function SlideLooper(axis: AxisType, viewSize: number, contentSize: number, slideSizesWithGaps: number[], scrollSnaps: number[], slidesInView: SlidesInViewType, scrollLocation: Vector1DType, slides: HTMLElement[]): SlideLooperType; | ||
export declare function SlideLooper(axis: AxisType, direction: DirectionType, viewSize: number, contentSize: number, slideSizesWithGaps: number[], scrollSnaps: number[], slidesInView: SlidesInViewType, scroll: Vector1DType, slides: HTMLElement[]): SlideLooperType; | ||
export {}; |
import { AxisType } from './Axis'; | ||
import { PxToPercentType } from './PxToPercent'; | ||
export declare type SlideSizesType = { | ||
@@ -7,2 +6,2 @@ slideSizes: number[]; | ||
}; | ||
export declare function SlideSizes(axis: AxisType, pxToPercent: PxToPercentType, slides: HTMLElement[], slideRects: DOMRect[], loop: boolean): SlideSizesType; | ||
export declare function SlideSizes(axis: AxisType, containerRect: DOMRect, slideRects: DOMRect[], slides: HTMLElement[], includeEdgeGap: boolean): SlideSizesType; |
export declare function map(value: number, iStart: number, iStop: number, oStart: number, oStop: number): number; | ||
export declare function isNumber(subject: unknown): subject is number; | ||
export declare function isObject(subject: unknown): subject is Record<string, unknown>; | ||
export declare function isArray(subject: unknown): subject is Record<number, unknown>; | ||
export declare function isRecord(subject: unknown): subject is Record<string | number, unknown>; | ||
export declare function mathAbs(n: number): number; | ||
@@ -7,6 +11,7 @@ export declare function mathSign(n: number): number; | ||
export declare function roundToDecimals(decimalPoints: number): (n: number) => number; | ||
export declare function debounce(callback: () => void, time: number): () => void; | ||
export declare function arrayGroup<GenericType>(array: GenericType[], size: number): GenericType[][]; | ||
export declare function arrayKeys<GenericType>(array: GenericType[]): number[]; | ||
export declare function arrayLast<GenericType>(array: GenericType[]): GenericType; | ||
export declare function arrayLastIndex<GenericType>(array: GenericType[]): number; | ||
export declare function arrayKeys<Type>(array: Type[]): number[]; | ||
export declare function arrayLast<Type>(array: Type[]): Type; | ||
export declare function arrayLastIndex<Type>(array: Type[]): number; | ||
export declare function objectKeys<Type>(object: Type): string[]; | ||
export declare function objectsMergeDeep(objectA: Record<string, unknown>, objectB: Record<string, unknown>): Record<string, unknown>; | ||
export declare function objectsAreEqual(objectA: Record<string, unknown>, objectB: Record<string, unknown>): boolean; |
@@ -0,1 +1,73 @@ | ||
function map(value, iStart, iStop, oStart, oStop) { | ||
return oStart + (oStop - oStart) * ((value - iStart) / (iStop - iStart)); | ||
} | ||
function isNumber(subject) { | ||
return typeof subject === 'number'; | ||
} | ||
function isObject(subject) { | ||
return Object.prototype.toString.call(subject) === '[object Object]'; | ||
} | ||
function isArray(subject) { | ||
return Array.isArray(subject); | ||
} | ||
function isRecord(subject) { | ||
return isObject(subject) || isArray(subject); | ||
} | ||
function mathAbs(n) { | ||
return Math.abs(n); | ||
} | ||
function mathSign(n) { | ||
return !n ? 0 : n / mathAbs(n); | ||
} | ||
function deltaAbs(valueB, valueA) { | ||
return mathAbs(valueB - valueA); | ||
} | ||
function factorAbs(valueB, valueA) { | ||
if (valueB === 0 || valueA === 0) return 0; | ||
if (mathAbs(valueB) <= mathAbs(valueA)) return 0; | ||
var diff = deltaAbs(mathAbs(valueB), mathAbs(valueA)); | ||
return mathAbs(diff / valueB); | ||
} | ||
function roundToDecimals(decimalPoints) { | ||
var pow = Math.pow(10, decimalPoints); | ||
return function (n) { | ||
return Math.round(n * pow) / pow; | ||
}; | ||
} | ||
function arrayKeys(array) { | ||
return objectKeys(array).map(Number); | ||
} | ||
function arrayLast(array) { | ||
return array[arrayLastIndex(array)]; | ||
} | ||
function arrayLastIndex(array) { | ||
return Math.max(0, array.length - 1); | ||
} | ||
function objectKeys(object) { | ||
return Object.keys(object); | ||
} | ||
function objectsMergeDeep(objectA, objectB) { | ||
return [objectA, objectB].reduce(function (mergedObjects, currentObject) { | ||
objectKeys(currentObject).forEach(function (key) { | ||
var valueA = mergedObjects[key]; | ||
var valueB = currentObject[key]; | ||
var areObjects = isObject(valueA) && isObject(valueB); | ||
mergedObjects[key] = areObjects ? objectsMergeDeep(valueA, valueB) : valueB; | ||
}); | ||
return mergedObjects; | ||
}, {}); | ||
} | ||
function objectsAreEqual(objectA, objectB) { | ||
var objectAKeys = objectKeys(objectA); | ||
var objectBKeys = objectKeys(objectB); | ||
if (objectAKeys.length !== objectBKeys.length) return false; | ||
return objectAKeys.every(function (key) { | ||
var valueA = objectA[key]; | ||
var valueB = objectB[key]; | ||
if (typeof valueA === 'function') return "".concat(valueA) === "".concat(valueB); | ||
if (!isRecord(valueA) || !isRecord(valueB)) return valueA === valueB; | ||
return objectsAreEqual(valueA, valueB); | ||
}); | ||
} | ||
function Alignment(align, viewSize) { | ||
@@ -25,3 +97,3 @@ var predefined = { | ||
function measure(n) { | ||
if (typeof align === 'number') return percent(); | ||
if (isNumber(align)) return percent(); | ||
return predefined[align](n); | ||
@@ -94,52 +166,2 @@ } | ||
function map(value, iStart, iStop, oStart, oStop) { | ||
return oStart + (oStop - oStart) * ((value - iStart) / (iStop - iStart)); | ||
} | ||
function mathAbs(n) { | ||
return Math.abs(n); | ||
} | ||
function mathSign(n) { | ||
return !n ? 0 : n / mathAbs(n); | ||
} | ||
function deltaAbs(valueB, valueA) { | ||
return mathAbs(valueB - valueA); | ||
} | ||
function factorAbs(valueB, valueA) { | ||
if (valueB === 0 || valueA === 0) return 0; | ||
if (mathAbs(valueB) <= mathAbs(valueA)) return 0; | ||
var diff = deltaAbs(mathAbs(valueB), mathAbs(valueA)); | ||
return mathAbs(diff / valueB); | ||
} | ||
function roundToDecimals(decimalPoints) { | ||
var pow = Math.pow(10, decimalPoints); | ||
return function (n) { | ||
return Math.round(n * pow) / pow; | ||
}; | ||
} | ||
function debounce(callback, time) { | ||
var timeout = 0; | ||
return function () { | ||
window.clearTimeout(timeout); | ||
timeout = window.setTimeout(callback, time) || 0; | ||
}; | ||
} | ||
function arrayGroup(array, size) { | ||
var groups = []; | ||
for (var i = 0; i < array.length; i += size) { | ||
groups.push(array.slice(i, i + size)); | ||
} | ||
return groups; | ||
} | ||
function arrayKeys(array) { | ||
return Object.keys(array).map(Number); | ||
} | ||
function arrayLast(array) { | ||
return array[arrayLastIndex(array)]; | ||
} | ||
function arrayLastIndex(array) { | ||
return Math.max(0, array.length - 1); | ||
} | ||
function Limit(min, max) { | ||
@@ -303,3 +325,3 @@ var length = mathAbs(min - max); | ||
function readNumber(n) { | ||
return typeof n === 'number' ? n : n.get(); | ||
return isNumber(n) ? n : n.get(); | ||
} | ||
@@ -319,3 +341,3 @@ | ||
function DragHandler(axis, direction, rootNode, target, dragFree, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, events, loop, skipSnaps) { | ||
function DragHandler(axis, direction, rootNode, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, loop, dragFree, skipSnaps) { | ||
var crossAxis = axis.cross; | ||
@@ -326,2 +348,3 @@ var focusNodes = ['INPUT', 'SELECT', 'TEXTAREA']; | ||
var interactionEvents = EventStore(); | ||
var dragThreshold = percentOfView.measure(20); | ||
var snapForceBoost = { | ||
@@ -337,3 +360,2 @@ mouse: 300, | ||
var baseMass = 1; | ||
var dragThreshold = 20; | ||
var startScroll = 0; | ||
@@ -401,3 +423,3 @@ var startCross = 0; | ||
startCross = dragTracker.readPoint(evt, crossAxis); | ||
events.emit('pointerDown'); | ||
eventHandler.emit('pointerDown'); | ||
if (clearPreventClick) preventClick = false; | ||
@@ -443,3 +465,3 @@ if (preventDefault) evt.preventDefault(); | ||
isMouse = false; | ||
events.emit('pointerUp'); | ||
eventHandler.emit('pointerUp'); | ||
} | ||
@@ -468,3 +490,3 @@ | ||
function DragTracker(axis, pxToPercent) { | ||
function DragTracker(axis) { | ||
var logInterval = 170; | ||
@@ -484,3 +506,3 @@ var startEvent; | ||
var property = evtAxis || axis.scroll; | ||
var coord = "client" + (property === 'x' ? 'X' : 'Y'); | ||
var coord = "client".concat(property === 'x' ? 'X' : 'Y'); | ||
return (isTouchEvent(evt) ? evt.touches[0] : evt)[coord]; | ||
@@ -492,3 +514,3 @@ } | ||
lastEvent = evt; | ||
return pxToPercent.measure(readPoint(evt)); | ||
return readPoint(evt); | ||
} | ||
@@ -501,3 +523,3 @@ | ||
if (expired) startEvent = evt; | ||
return pxToPercent.measure(diff); | ||
return diff; | ||
} | ||
@@ -512,3 +534,3 @@ | ||
var isFlick = diffTime && !expired && mathAbs(force) > 0.1; | ||
return isFlick ? pxToPercent.measure(force) : 0; | ||
return isFlick ? force : 0; | ||
} | ||
@@ -526,13 +548,9 @@ | ||
function PxToPercent(viewInPx) { | ||
var totalPercent = 100; | ||
function PercentOfView(viewSize) { | ||
function measure(n) { | ||
if (viewInPx === 0) return 0; | ||
return n / viewInPx * totalPercent; | ||
return viewSize * (n / 100); | ||
} | ||
var self = { | ||
measure: measure, | ||
totalPercent: totalPercent | ||
measure: measure | ||
}; | ||
@@ -613,5 +631,5 @@ return self; | ||
function ScrollBounds(limit, location, target, scrollBody) { | ||
var pullBackThreshold = 10; | ||
var edgeOffsetTolerance = 50; | ||
function ScrollBounds(limit, location, target, scrollBody, percentOfView) { | ||
var pullBackThreshold = percentOfView.measure(10); | ||
var edgeOffsetTolerance = percentOfView.measure(50); | ||
var maxFriction = 0.85; | ||
@@ -652,4 +670,4 @@ var disabled = false; | ||
function ScrollContain(viewSize, contentSize, snaps, snapsAligned, containScroll) { | ||
var scrollBounds = Limit(-contentSize + viewSize, snaps[0]); | ||
function ScrollContain(viewSize, contentSize, snapsAligned, containScroll) { | ||
var scrollBounds = Limit(-contentSize + viewSize, snapsAligned[0]); | ||
var snapsBounded = snapsAligned.map(scrollBounds.constrain); | ||
@@ -700,5 +718,6 @@ var snapsContained = measureContained(); | ||
function ScrollLooper(contentSize, pxToPercent, limit, location, vectors) { | ||
var min = limit.min + pxToPercent.measure(0.1); | ||
var max = limit.max + pxToPercent.measure(0.1); | ||
function ScrollLooper(contentSize, limit, location, vectors) { | ||
var jointSafety = 0.1; | ||
var min = limit.min + jointSafety; | ||
var max = limit.max + jointSafety; | ||
@@ -744,5 +763,7 @@ var _a = Limit(min, max), | ||
function ScrollSnap(axis, alignment, pxToPercent, containerRect, slideRects, slidesToScroll) { | ||
function ScrollSnaps(axis, alignment, containerRect, slideRects, slideSizesWithGaps, slidesToScroll, containScroll) { | ||
var startEdge = axis.startEdge, | ||
endEdge = axis.endEdge; | ||
var groupSlides = slidesToScroll.groupSlides; | ||
var alignments = measureSizes().map(alignment.measure); | ||
var snaps = measureUnaligned(); | ||
@@ -752,5 +773,5 @@ var snapsAligned = measureAligned(); | ||
function measureSizes() { | ||
return arrayGroup(slideRects, slidesToScroll).map(function (rects) { | ||
return groupSlides(slideRects).map(function (rects) { | ||
return arrayLast(rects)[endEdge] - rects[0][startEdge]; | ||
}).map(pxToPercent.measure).map(mathAbs); | ||
}).map(mathAbs); | ||
} | ||
@@ -761,3 +782,3 @@ | ||
return containerRect[startEdge] - rect[startEdge]; | ||
}).map(pxToPercent.measure).map(function (snap) { | ||
}).map(function (snap) { | ||
return -mathAbs(snap); | ||
@@ -768,7 +789,11 @@ }); | ||
function measureAligned() { | ||
var groupedSnaps = arrayGroup(snaps, slidesToScroll).map(function (g) { | ||
var containedStartSnap = 0; | ||
var containedEndSnap = arrayLast(snaps) - arrayLast(slideSizesWithGaps); | ||
return groupSlides(snaps).map(function (g) { | ||
return g[0]; | ||
}); | ||
var alignments = measureSizes().map(alignment.measure); | ||
return groupedSnaps.map(function (snap, index) { | ||
}).map(function (snap, index, groupedSnaps) { | ||
var isFirst = !index; | ||
var isLast = index === arrayLastIndex(groupedSnaps); | ||
if (containScroll && isFirst) return containedStartSnap; | ||
if (containScroll && isLast) return containedEndSnap; | ||
return snap + alignments[index]; | ||
@@ -862,3 +887,3 @@ }); | ||
function ScrollTo(animation, indexCurrent, indexPrevious, scrollTarget, targetVector, events) { | ||
function ScrollTo(animation, indexCurrent, indexPrevious, scrollTarget, targetVector, eventHandler) { | ||
function scrollTo(target) { | ||
@@ -876,3 +901,3 @@ var distanceDiff = target.distance; | ||
indexCurrent.set(target.index); | ||
events.emit('select'); | ||
eventHandler.emit('select'); | ||
} | ||
@@ -899,3 +924,39 @@ } | ||
function SlideLooper(axis, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, scrollLocation, slides) { | ||
function Translate(axis, direction, container) { | ||
var translate = axis.scroll === 'x' ? x : y; | ||
var containerStyle = container.style; | ||
var disabled = false; | ||
function x(n) { | ||
return "translate3d(".concat(n, "px,0px,0px)"); | ||
} | ||
function y(n) { | ||
return "translate3d(0px,".concat(n, "px,0px)"); | ||
} | ||
function to(target) { | ||
if (disabled) return; | ||
containerStyle.transform = translate(direction.apply(target.get())); | ||
} | ||
function toggleActive(active) { | ||
disabled = !active; | ||
} | ||
function clear() { | ||
if (disabled) return; | ||
containerStyle.transform = ''; | ||
if (!container.getAttribute('style')) container.removeAttribute('style'); | ||
} | ||
var self = { | ||
clear: clear, | ||
to: to, | ||
toggleActive: toggleActive | ||
}; | ||
return self; | ||
} | ||
function SlideLooper(axis, direction, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, scroll, slides) { | ||
var ascItems = arrayKeys(slideSizesWithGaps); | ||
@@ -929,12 +990,15 @@ var descItems = arrayKeys(slideSizesWithGaps).reverse(); | ||
var point = bounds[isStartEdge ? 'end' : 'start']; | ||
var shift = Vector1D(-1); | ||
var location = Vector1D(-1); | ||
var translate = Translate(axis, direction, slides[index]); | ||
var getTarget = function () { | ||
return scrollLocation.get() > point ? initial : altered; | ||
var target = function () { | ||
return shift.set(scroll.get() > point ? initial : altered); | ||
}; | ||
return { | ||
point: point, | ||
getTarget: getTarget, | ||
index: index, | ||
location: -1 | ||
location: location, | ||
translate: translate, | ||
target: target | ||
}; | ||
@@ -968,11 +1032,9 @@ }); | ||
loopPoints.forEach(function (loopPoint) { | ||
var getTarget = loopPoint.getTarget, | ||
location = loopPoint.location, | ||
index = loopPoint.index; | ||
var target = getTarget(); | ||
if (target !== location) { | ||
slides[index].style[axis.startEdge] = target + "%"; | ||
loopPoint.location = target; | ||
} | ||
var target = loopPoint.target, | ||
translate = loopPoint.translate, | ||
location = loopPoint.location; | ||
var shift = target(); | ||
if (shift.get() === location.get()) return; | ||
if (shift.get() === 0) translate.clear();else translate.to(shift); | ||
location.set(shift); | ||
}); | ||
@@ -982,5 +1044,4 @@ } | ||
function clear() { | ||
loopPoints.forEach(function (_a) { | ||
var index = _a.index; | ||
slides[index].style[axis.startEdge] = ''; | ||
loopPoints.forEach(function (loopPoint) { | ||
return loopPoint.translate.clear(); | ||
}); | ||
@@ -1001,17 +1062,22 @@ } | ||
constrain = limit.constrain; | ||
var cachedThreshold = Math.min(Math.max(inViewThreshold, 0.01), 0.99); | ||
var roundingSafety = 0.5; | ||
var cachedOffsets = loop ? [0, contentSize, -contentSize] : [0]; | ||
var cachedBounds = findSlideBounds(cachedOffsets, cachedThreshold); | ||
var cachedBounds = findSlideBounds(cachedOffsets, inViewThreshold); | ||
function findSlideThresholds(threshold) { | ||
var slideThreshold = threshold || 0; | ||
return slideSizes.map(function (slideSize) { | ||
var thresholdLimit = Limit(roundingSafety, slideSize - roundingSafety); | ||
return thresholdLimit.constrain(slideSize * slideThreshold); | ||
}); | ||
} | ||
function findSlideBounds(offsets, threshold) { | ||
var slideOffsets = offsets || cachedOffsets; | ||
var slideThreshold = threshold || 0; | ||
var thresholds = slideSizes.map(function (s) { | ||
return s * slideThreshold; | ||
}); | ||
var slideThresholds = findSlideThresholds(threshold); | ||
return slideOffsets.reduce(function (list, offset) { | ||
var bounds = snaps.map(function (snap, index) { | ||
return { | ||
start: snap - slideSizes[index] + thresholds[index] + offset, | ||
end: snap + viewSize - thresholds[index] + offset, | ||
start: snap - slideSizes[index] + slideThresholds[index] + offset, | ||
end: snap + viewSize - slideThresholds[index] + offset, | ||
index: index | ||
@@ -1044,18 +1110,31 @@ }; | ||
function SlideSizes(axis, pxToPercent, slides, slideRects, loop) { | ||
function SlideSizes(axis, containerRect, slideRects, slides, includeEdgeGap) { | ||
var measureSize = axis.measureSize, | ||
startEdge = axis.startEdge, | ||
endEdge = axis.endEdge; | ||
var sizesInPx = slideRects.map(measureSize); | ||
var slideSizes = sizesInPx.map(pxToPercent.measure); | ||
var startGap = measureStartGap(); | ||
var endGap = measureEndGap(); | ||
var slideSizes = slideRects.map(measureSize); | ||
var slideSizesWithGaps = measureWithGaps(); | ||
function measureStartGap() { | ||
if (!includeEdgeGap) return 0; | ||
var slideRect = slideRects[0]; | ||
return mathAbs(containerRect[startEdge] - slideRect[startEdge]); | ||
} | ||
function measureEndGap() { | ||
if (!includeEdgeGap) return 0; | ||
var style = window.getComputedStyle(arrayLast(slides)); | ||
return parseFloat(style.getPropertyValue("margin-".concat(endEdge))); | ||
} | ||
function measureWithGaps() { | ||
return slideRects.map(function (rect, index, rects) { | ||
var isFirst = !index; | ||
var isLast = index === arrayLastIndex(rects); | ||
var style = window.getComputedStyle(arrayLast(slides)); | ||
var endGap = parseFloat(style.getPropertyValue("margin-" + endEdge)); | ||
if (isLast) return sizesInPx[index] + (loop ? endGap : 0); | ||
if (isFirst) return slideSizes[index] + startGap; | ||
if (isLast) return slideSizes[index] + endGap; | ||
return rects[index + 1][startEdge] - rect[startEdge]; | ||
}).map(pxToPercent.measure).map(mathAbs); | ||
}).map(mathAbs); | ||
} | ||
@@ -1070,32 +1149,31 @@ | ||
function Translate(axis, direction, container) { | ||
var translate = axis.scroll === 'x' ? x : y; | ||
var containerStyle = container.style; | ||
var disabled = false; | ||
function SlidesToScroll(viewSize, slideSizesWithGaps, slidesToScroll) { | ||
var groupByNumber = isNumber(slidesToScroll); | ||
function x(n) { | ||
return "translate3d(" + n + "%,0px,0px)"; | ||
function byNumber(array, groupSize) { | ||
return arrayKeys(array).filter(function (i) { | ||
return i % groupSize === 0; | ||
}).map(function (i) { | ||
return array.slice(i, i + groupSize); | ||
}); | ||
} | ||
function y(n) { | ||
return "translate3d(0px," + n + "%,0px)"; | ||
function bySize(array) { | ||
return arrayKeys(array).reduce(function (groupSizes, i) { | ||
var chunk = slideSizesWithGaps.slice(arrayLast(groupSizes), i + 1); | ||
var chunkSize = chunk.reduce(function (a, s) { | ||
return a + s; | ||
}, 0); | ||
return !i || chunkSize > viewSize ? groupSizes.concat(i) : groupSizes; | ||
}, []).map(function (start, i, groupSizes) { | ||
return array.slice(start, groupSizes[i + 1]); | ||
}); | ||
} | ||
function to(target) { | ||
if (disabled) return; | ||
containerStyle.transform = translate(direction.apply(target.get())); | ||
function groupSlides(array) { | ||
return groupByNumber ? byNumber(array, slidesToScroll) : bySize(array); | ||
} | ||
function toggleActive(active) { | ||
disabled = !active; | ||
} | ||
function clear() { | ||
containerStyle.transform = ''; | ||
} | ||
var self = { | ||
clear: clear, | ||
to: to, | ||
toggleActive: toggleActive | ||
groupSlides: groupSlides | ||
}; | ||
@@ -1105,3 +1183,3 @@ return self; | ||
function Engine(root, container, slides, options, events) { | ||
function Engine(root, container, slides, options, eventHandler) { | ||
// Options | ||
@@ -1116,3 +1194,3 @@ var align = options.align, | ||
dragFree = options.dragFree, | ||
slidesToScroll = options.slidesToScroll, | ||
groupSlides = options.slidesToScroll, | ||
skipSnaps = options.skipSnaps, | ||
@@ -1127,11 +1205,15 @@ containScroll = options.containScroll; // Measurements | ||
var axis = Axis(scrollAxis, contentDirection); | ||
var pxToPercent = PxToPercent(axis.measureSize(containerRect)); | ||
var viewSize = pxToPercent.totalPercent; | ||
var viewSize = axis.measureSize(containerRect); | ||
var percentOfView = PercentOfView(viewSize); | ||
var alignment = Alignment(align, viewSize); | ||
var containSnaps = !loop && containScroll !== ''; | ||
var includeEdgeGap = loop || containScroll !== ''; | ||
var _a = SlideSizes(axis, pxToPercent, slides, slideRects, loop), | ||
var _a = SlideSizes(axis, containerRect, slideRects, slides, includeEdgeGap), | ||
slideSizes = _a.slideSizes, | ||
slideSizesWithGaps = _a.slideSizesWithGaps; | ||
var _b = ScrollSnap(axis, alignment, pxToPercent, containerRect, slideRects, slidesToScroll), | ||
var slidesToScroll = SlidesToScroll(viewSize, slideSizesWithGaps, groupSlides); | ||
var _b = ScrollSnaps(axis, alignment, containerRect, slideRects, slideSizesWithGaps, slidesToScroll, containSnaps), | ||
snaps = _b.snaps, | ||
@@ -1141,5 +1223,4 @@ snapsAligned = _b.snapsAligned; | ||
var contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps); | ||
var snapsContained = ScrollContain(viewSize, contentSize, snaps, snapsAligned, containScroll).snapsContained; | ||
var contain = !loop && containScroll !== ''; | ||
var scrollSnaps = contain ? snapsContained : snapsAligned; | ||
var snapsContained = ScrollContain(viewSize, contentSize, snapsAligned, containScroll).snapsContained; | ||
var scrollSnaps = containSnaps ? snapsContained : snapsAligned; | ||
var limit = ScrollLimit(contentSize, scrollSnaps, loop).limit; // Indexes | ||
@@ -1158,7 +1239,7 @@ | ||
engine.animation.stop(); | ||
events.emit('settle'); | ||
eventHandler.emit('settle'); | ||
} | ||
if (!settled) { | ||
events.emit('scroll'); | ||
eventHandler.emit('scroll'); | ||
} | ||
@@ -1182,6 +1263,6 @@ | ||
var scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target); | ||
var scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, events); | ||
var scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, eventHandler); | ||
var slidesInView = SlidesInView(viewSize, contentSize, slideSizes, snaps, limit, loop, inViewThreshold); // DragHandler | ||
var dragHandler = DragHandler(axis, direction, root, target, dragFree, DragTracker(axis, pxToPercent), location, animation, scrollTo, scrollBody, scrollTarget, index, events, loop, skipSnaps); // Slider | ||
var dragHandler = DragHandler(axis, direction, root, target, DragTracker(axis), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, loop, dragFree, skipSnaps); // Engine | ||
@@ -1196,3 +1277,3 @@ var engine = { | ||
eventStore: EventStore(), | ||
pxToPercent: pxToPercent, | ||
percentOfView: percentOfView, | ||
index: index, | ||
@@ -1204,4 +1285,4 @@ indexPrevious: indexPrevious, | ||
scrollBody: scrollBody, | ||
scrollBounds: ScrollBounds(limit, location, target, scrollBody), | ||
scrollLooper: ScrollLooper(contentSize, pxToPercent, limit, location, [location, target]), | ||
scrollBounds: ScrollBounds(limit, location, target, scrollBody, percentOfView), | ||
scrollLooper: ScrollLooper(contentSize, limit, location, [location, target]), | ||
scrollProgress: ScrollProgress(limit), | ||
@@ -1211,3 +1292,4 @@ scrollSnaps: scrollSnaps, | ||
scrollTo: scrollTo, | ||
slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, location, slides), | ||
slideLooper: SlideLooper(axis, direction, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, location, slides), | ||
slidesToScroll: slidesToScroll, | ||
slidesInView: slidesInView, | ||
@@ -1221,3 +1303,3 @@ slideIndexes: slideIndexes, | ||
function EventEmitter() { | ||
function EventHandler() { | ||
var listeners = {}; | ||
@@ -1261,2 +1343,4 @@ | ||
direction: 'ltr', | ||
slidesToScroll: 1, | ||
breakpoints: {}, | ||
dragFree: false, | ||
@@ -1267,21 +1351,85 @@ draggable: true, | ||
skipSnaps: false, | ||
slidesToScroll: 1, | ||
speed: 10, | ||
startIndex: 0 | ||
startIndex: 0, | ||
active: true | ||
}; | ||
function OptionsPseudo(node) { | ||
var pseudoString = getComputedStyle(node, ':before').content; | ||
function OptionsHandler() { | ||
function merge(optionsA, optionsB) { | ||
return objectsMergeDeep(optionsA, optionsB || {}); | ||
} | ||
function get() { | ||
try { | ||
return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, '')); | ||
} catch (error) {} // eslint-disable-line no-empty | ||
function areEqual(optionsA, optionsB) { | ||
var breakpointsA = JSON.stringify(objectKeys(optionsA.breakpoints || {})); | ||
var breakpointsB = JSON.stringify(objectKeys(optionsB.breakpoints || {})); | ||
if (breakpointsA !== breakpointsB) return false; | ||
return objectsAreEqual(optionsA, optionsB); | ||
} | ||
function atMedia(options) { | ||
var optionsAtMedia = options.breakpoints || {}; | ||
var matchedMediaOptions = objectKeys(optionsAtMedia).filter(function (media) { | ||
return window.matchMedia(media).matches; | ||
}).map(function (media) { | ||
return optionsAtMedia[media]; | ||
}).reduce(function (a, mediaOption) { | ||
return merge(a, mediaOption); | ||
}, {}); | ||
return merge(options, matchedMediaOptions); | ||
} | ||
return {}; | ||
var self = { | ||
merge: merge, | ||
areEqual: areEqual, | ||
atMedia: atMedia | ||
}; | ||
return self; | ||
} | ||
function PluginsHandler() { | ||
var _a = OptionsHandler(), | ||
atMedia = _a.atMedia, | ||
areEqual = _a.areEqual; | ||
var activePlugins; | ||
var pluginsChanged = []; | ||
function haveChanged() { | ||
return pluginsChanged.some(function (hasChanged) { | ||
return hasChanged(); | ||
}); | ||
} | ||
function hasChanged(plugin) { | ||
var options = atMedia(plugin.options); | ||
return function () { | ||
return !areEqual(options, atMedia(plugin.options)); | ||
}; | ||
} | ||
function init(plugins, embla) { | ||
pluginsChanged = plugins.map(hasChanged); | ||
activePlugins = plugins.filter(function (plugin) { | ||
return atMedia(plugin.options).active; | ||
}); | ||
activePlugins.forEach(function (plugin) { | ||
return plugin.init(embla); | ||
}); | ||
return plugins.reduce(function (map, plugin) { | ||
var _a; | ||
return Object.assign(map, (_a = {}, _a[plugin.name] = plugin, _a)); | ||
}, {}); | ||
} | ||
function destroy() { | ||
activePlugins = activePlugins.filter(function (plugin) { | ||
return plugin.destroy(); | ||
}); | ||
} | ||
var self = { | ||
get: get | ||
init: init, | ||
destroy: destroy, | ||
haveChanged: haveChanged | ||
}; | ||
@@ -1292,13 +1440,15 @@ return self; | ||
function EmblaCarousel(nodes, userOptions, userPlugins) { | ||
var events = EventEmitter(); | ||
var debouncedResize = debounce(resize, 500); | ||
var resizeHandlers = EventStore(); | ||
var optionsHandler = OptionsHandler(); | ||
var pluginsHandler = PluginsHandler(); | ||
var eventHandler = EventHandler(); | ||
var on = eventHandler.on, | ||
off = eventHandler.off; | ||
var reInit = reActivate; | ||
var on = events.on, | ||
off = events.off; | ||
var destroyed = false; | ||
var engine; | ||
var activated = false; | ||
var optionsBase = Object.assign({}, defaultOptions, EmblaCarousel.globalOptions); | ||
var options = Object.assign({}, optionsBase); | ||
var optionsPseudo; | ||
var plugins; | ||
var optionsBase = optionsHandler.merge(defaultOptions, EmblaCarousel.globalOptions); | ||
var options = optionsHandler.merge(optionsBase); | ||
var pluginList = []; | ||
var pluginApis; | ||
var rootSize = 0; | ||
@@ -1309,3 +1459,3 @@ var root; | ||
function setupElements() { | ||
function storeElements() { | ||
var providedContainer = 'container' in nodes && nodes.container; | ||
@@ -1316,17 +1466,15 @@ var providedSlides = 'slides' in nodes && nodes.slides; | ||
slides = providedSlides || [].slice.call(container.children); | ||
optionsPseudo = OptionsPseudo(root); | ||
} | ||
function activate(withOptions, withPlugins) { | ||
setupElements(); | ||
optionsBase = Object.assign({}, optionsBase, withOptions); | ||
options = Object.assign({}, optionsBase, optionsPseudo.get()); | ||
plugins = Object.assign([], withPlugins); | ||
engine = Engine(root, container, slides, options, events); | ||
engine.eventStore.add(window, 'resize', debouncedResize); | ||
if (destroyed) return; | ||
storeElements(); | ||
optionsBase = optionsHandler.merge(optionsBase, withOptions); | ||
options = optionsHandler.atMedia(optionsBase); | ||
engine = Engine(root, container, slides, options, eventHandler); | ||
rootSize = engine.axis.measureSize(root.getBoundingClientRect()); | ||
if (!options.active) return deActivate(); | ||
engine.translate.to(engine.location); | ||
rootSize = engine.axis.measureSize(root.getBoundingClientRect()); | ||
plugins.forEach(function (plugin) { | ||
return plugin.init(self); | ||
}); | ||
pluginList = withPlugins || pluginList; | ||
pluginApis = pluginsHandler.init(pluginList, self); | ||
@@ -1347,20 +1495,11 @@ if (options.loop) { | ||
} | ||
if (!activated) { | ||
setTimeout(function () { | ||
return events.emit('init'); | ||
}, 0); | ||
activated = true; | ||
} | ||
} | ||
function reActivate(withOptions, withPlugins) { | ||
if (!activated) return; | ||
var startIndex = selectedScrollSnap(); | ||
var newOptions = Object.assign({ | ||
deActivate(); | ||
activate(optionsHandler.merge({ | ||
startIndex: startIndex | ||
}, withOptions); | ||
deActivate(); | ||
activate(newOptions, withPlugins || plugins); | ||
events.emit('reInit'); | ||
}, withOptions), withPlugins); | ||
eventHandler.emit('reInit'); | ||
} | ||
@@ -1374,19 +1513,21 @@ | ||
engine.slideLooper.clear(); | ||
plugins.forEach(function (plugin) { | ||
return plugin.destroy(); | ||
}); | ||
pluginsHandler.destroy(); | ||
} | ||
function destroy() { | ||
if (!activated) return; | ||
if (destroyed) return; | ||
destroyed = true; | ||
resizeHandlers.removeAll(); | ||
deActivate(); | ||
activated = false; | ||
events.emit('destroy'); | ||
eventHandler.emit('destroy'); | ||
} | ||
function resize() { | ||
if (!activated) return; | ||
var size = engine.axis.measureSize(root.getBoundingClientRect()); | ||
if (rootSize !== size) reActivate(); | ||
events.emit('resize'); | ||
var newOptions = optionsHandler.atMedia(optionsBase); | ||
var optionsChanged = !optionsHandler.areEqual(newOptions, options); | ||
var newRootSize = engine.axis.measureSize(root.getBoundingClientRect()); | ||
var rootSizeChanged = rootSize !== newRootSize; | ||
var pluginsChanged = pluginsHandler.haveChanged(); | ||
if (rootSizeChanged || optionsChanged || pluginsChanged) reActivate(); | ||
eventHandler.emit('resize'); | ||
} | ||
@@ -1408,4 +1549,5 @@ | ||
function scrollTo(index, jump, direction) { | ||
if (!options.active || destroyed) return; | ||
engine.scrollBody.useBaseMass().useSpeed(jump ? 100 : options.speed); | ||
if (activated) engine.scrollTo.index(index, direction || 0); | ||
engine.scrollTo.index(index, direction || 0); | ||
} | ||
@@ -1453,2 +1595,6 @@ | ||
function plugins() { | ||
return pluginApis; | ||
} | ||
function internalEngine() { | ||
@@ -1479,2 +1625,3 @@ return engine; | ||
on: on, | ||
plugins: plugins, | ||
previousScrollSnap: previousScrollSnap, | ||
@@ -1494,2 +1641,6 @@ reInit: reInit, | ||
activate(userOptions, userPlugins); | ||
resizeHandlers.add(window, 'resize', resize); | ||
setTimeout(function () { | ||
return eventHandler.emit('init'); | ||
}, 0); | ||
return self; | ||
@@ -1499,4 +1650,5 @@ } | ||
EmblaCarousel.globalOptions = undefined; | ||
EmblaCarousel.optionsHandler = OptionsHandler; | ||
export default EmblaCarousel; | ||
export { EmblaCarousel as default }; | ||
//# sourceMappingURL=embla-carousel.esm.js.map |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarousel=e()}(this,(function(){"use strict";function n(n,e){var t={start:function(){return 0},center:function(n){return r(n)/2},end:r};function r(n){return e-n}return{measure:function(r){return"number"==typeof n?e*Number(n):t[n](r)}}}function e(n){return Math.abs(n)}function t(n){return n?n/e(n):0}function r(n,t){return e(n-t)}function o(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function i(n){return Object.keys(n).map(Number)}function u(n){return n[c(n)]}function c(n){return Math.max(0,n.length-1)}function a(n,t){var r=e(n-t);function o(e){return e<n}function i(n){return n>t}function u(n){return o(n)||i(n)}return{length:r,max:t,min:n,constrain:function(e){return u(e)?o(e)?n:t:e},reachedAny:u,reachedMax:i,reachedMin:o,removeOffset:function(n){return r?n-r*Math.ceil((n-t)/r):n}}}function s(n,t,r){var o=a(0,n),i=o.min,u=o.constrain,c=n+1,d=f(t);function f(n){return r?e((c+n)%c):u(n)}function l(){return d}function p(n){return d=f(n),m}var m={add:function(n){return p(l()+n)},clone:function(){return s(n,l(),r)},get:l,set:p,min:i,max:n};return m}function d(){var n=[];var e={add:function(t,r,o,i){return void 0===i&&(i=!1),t.addEventListener(r,o,i),n.push((function(){return t.removeEventListener(r,o,i)})),e},removeAll:function(){return n=n.filter((function(n){return n()})),e}};return e}function f(n){var e=n;function t(n){return e/=n,o}function r(n){return"number"==typeof n?n:n.get()}var o={add:function(n){return e+=r(n),o},divide:t,get:function(){return e},multiply:function(n){return e*=n,o},normalize:function(){return 0!==e&&t(e),o},set:function(n){return e=r(n),o},subtract:function(n){return e-=r(n),o}};return o}function l(n,o,i,u,c,a,s,l,p,m,v,g,x,h,y){var S=n.cross,b=["INPUT","SELECT","TEXTAREA"],w=f(0),E=d(),A=d(),T={mouse:300,touch:400},M={mouse:500,touch:600},P=c?5:16,O=0,B=0,I=!1,z=!1,D=!1,L=!1;function k(n){if(!(L="mousedown"===n.type)||0===n.button){var e,t,o=r(u.get(),s.get())>=2,c=L||!o,d=(e=n.target,t=e.nodeName||"",!(b.indexOf(t)>-1)),f=o||L&&d;I=!0,a.pointerDown(n),w.set(u),u.set(s),m.useBaseMass().useSpeed(80),function(){var n=L?document:i;A.add(n,"touchmove",N).add(n,"touchend",C).add(n,"mousemove",N).add(n,"mouseup",C)}(),O=a.readPoint(n),B=a.readPoint(n,S),x.emit("pointerDown"),c&&(D=!1),f&&n.preventDefault()}}function N(n){if(!z&&!L){if(!n.cancelable)return C(n);var e=a.readPoint(n),t=a.readPoint(n,S),i=r(e,O),c=r(t,B);if(!(z=i>c)&&!D)return C(n)}var s=a.pointerMove(n);!D&&s&&(D=!0),l.start(),u.add(o.apply(s)),n.preventDefault()}function C(n){var i=v.byDistance(0,!1).index!==g.get(),s=a.pointerUp(n)*(c?M:T)[L?"mouse":"touch"],d=function(n,r){var o=g.clone().add(-1*t(n)),i=o.get()===g.min||o.get()===g.max,u=v.byDistance(n,!c).distance;return c||e(n)<20?u:!h&&i?.4*u:y&&r?.5*u:v.byIndex(o.get(),0).distance}(o.apply(s),i),f=function(n,t){if(0===n||0===t)return 0;if(e(n)<=e(t))return 0;var o=r(e(n),e(t));return e(o/n)}(s,d),l=r(u.get(),w.get())>=.5,S=i&&f>.75,b=e(s)<20,E=S?10:P,O=S?1+2.5*f:1;l&&!L&&(D=!0),z=!1,I=!1,A.removeAll(),m.useSpeed(b?9:E).useMass(O),p.distance(d,!c),L=!1,x.emit("pointerUp")}function j(n){D&&n.preventDefault()}return{addActivationEvents:function(){var n=i;E.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",k).add(n,"mousedown",k).add(n,"touchcancel",C).add(n,"contextmenu",C).add(n,"click",j)},clickAllowed:function(){return!D},pointerDown:function(){return I},removeAllEvents:function(){E.removeAll(),A.removeAll()}}}function p(n,e,r){var o,i,u=(o=2,i=Math.pow(10,o),function(n){return Math.round(n*i)/i}),c=f(0),a=f(0),s=f(0),d=0,l=e,p=r;function m(n){return l=n,g}function v(n){return p=n,g}var g={direction:function(){return d},seek:function(e){s.set(e).subtract(n);var r,o,i,u,f=(r=s.get(),(i=0)+(r-(o=0))/(100-o)*(l-i));return d=t(s.get()),s.normalize().multiply(f).subtract(c),(u=s).divide(p),a.add(u),g},settle:function(e){var t=e.get()-n.get(),r=!u(t);return r&&n.set(e),r},update:function(){c.add(a),n.add(c),a.multiply(0)},useBaseMass:function(){return v(r)},useBaseSpeed:function(){return m(e)},useMass:v,useSpeed:m};return g}function m(n,t,r,o){var i=!1;return{constrain:function(u){if(!i&&n.reachedAny(r.get())&&n.reachedAny(t.get())){var c=n.reachedMin(t.get())?"min":"max",a=e(n[c]-t.get()),s=r.get()-t.get(),d=Math.min(a/50,.85);r.subtract(s*d),!u&&e(s)<10&&(r.set(n.constrain(r.get())),o.useSpeed(10).useMass(3))}},toggleActive:function(n){i=!n}}}function v(n,e,t,r,o){var i=a(-e+n,t[0]),c=r.map(i.constrain);return{snapsContained:function(){if(e<=n)return[i.max];if("keepSnaps"===o)return c;var t=function(){var n=c[0],e=u(c),t=c.lastIndexOf(n),r=c.indexOf(e)+1;return a(t,r)}(),r=t.min,s=t.max;return c.slice(r,s)}()}}function g(n,e,t,r,o){var i=a(t.min+e.measure(.1),t.max+e.measure(.1)),u=i.reachedMin,c=i.reachedMax;return{loop:function(e){if(function(n){return 1===n?c(r.get()):-1===n&&u(r.get())}(e)){var t=n*(-1*e);o.forEach((function(n){return n.add(t)}))}}}}function x(n){var e=n.max,t=n.length;return{get:function(n){return(n-e)/-t}}}function h(n,t,r,i,c,a){var s,d,f=n.startEdge,l=n.endEdge,p=c.map((function(n){return i[f]-n[f]})).map(r.measure).map((function(n){return-e(n)})),m=(s=o(p,a).map((function(n){return n[0]})),d=o(c,a).map((function(n){return u(n)[l]-n[0][f]})).map(r.measure).map(e).map(t.measure),s.map((function(n,e){return n+d[e]})));return{snaps:p,snapsAligned:m}}function y(n,t,r,o,i){var u=o.reachedAny,c=o.removeOffset,a=o.constrain;function s(n,t){return e(n)<e(t)?n:t}function d(t,o){var i=t,u=t+r,c=t-r;return n?o?e(s(i,1===o?u:c))*o:s(s(i,u),c):i}return{byDistance:function(r,o){var s=i.get()+r,f=function(r){var o=n?c(r):a(r);return{index:t.map((function(n){return n-o})).map((function(n){return d(n,0)})).map((function(n,e){return{diff:n,index:e}})).sort((function(n,t){return e(n.diff)-e(t.diff)}))[0].index,distance:o}}(s),l=f.index,p=f.distance,m=!n&&u(s);return!o||m?{index:l,distance:r}:{index:l,distance:r+d(t[l]-p,0)}},byIndex:function(n,e){return{index:n,distance:d(t[n]-i.get(),e)}},shortcut:d}}function S(n,e,t,r,o,u,c,a){var s,d=i(r),f=i(r).reverse(),l=(s=o[0]-1,v(m(f,s),"end")).concat(function(){var n=e-o[0]-1;return v(m(d,n),"start")}());function p(n,e){return n.reduce((function(n,e){return n-r[e]}),e)}function m(n,e){return n.reduce((function(n,t){return p(n,e)>0?n.concat([t]):n}),[])}function v(n,e){var r="start"===e,o=r?-t:t,i=u.findSlideBounds([o]);return n.map((function(n){var e=r?0:-t,o=r?t:0,u=i.filter((function(e){return e.index===n}))[0][r?"end":"start"];return{point:u,getTarget:function(){return c.get()>u?e:o},index:n,location:-1}}))}return{canLoop:function(){return l.every((function(n){var t=n.index;return p(d.filter((function(n){return n!==t})),e)<=0}))},clear:function(){l.forEach((function(e){var t=e.index;a[t].style[n.startEdge]=""}))},loop:function(){l.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,i=t();i!==r&&(a[o].style[n.startEdge]=i+"%",e.location=i)}))},loopPoints:l}}function b(n,e,t){var r="x"===n.scroll?function(n){return"translate3d("+n+"%,0px,0px)"}:function(n){return"translate3d(0px,"+n+"%,0px)"},o=t.style,i=!1;return{clear:function(){o.transform=""},to:function(n){i||(o.transform=r(e.apply(n.get())))},toggleActive:function(n){i=!n}}}function w(t,r,o,w,E){var A,T=w.align,M=w.axis,P=w.direction,O=w.startIndex,B=w.inViewThreshold,I=w.loop,z=w.speed,D=w.dragFree,L=w.slidesToScroll,k=w.skipSnaps,N=w.containScroll,C=r.getBoundingClientRect(),j=o.map((function(n){return n.getBoundingClientRect()})),R=function(n){var e="rtl"===n?-1:1;return{apply:function(n){return n*e}}}(P),V=function(n,e){var t="y"===n?"y":"x";return{scroll:t,cross:"y"===n?"x":"y",startEdge:"y"===t?"top":"rtl"===e?"right":"left",endEdge:"y"===t?"bottom":"rtl"===e?"left":"right",measureSize:function(n){var e=n.width,r=n.height;return"x"===t?e:r}}}(M,P),H=(A=V.measureSize(C),{measure:function(n){return 0===A?0:n/A*100},totalPercent:100}),F=H.totalPercent,U=n(T,F),G=function(n,t,r,o,i){var a=n.measureSize,s=n.startEdge,d=n.endEdge,f=o.map(a);return{slideSizes:f.map(t.measure),slideSizesWithGaps:o.map((function(n,e,t){var o=e===c(t),a=window.getComputedStyle(u(r)),l=parseFloat(a.getPropertyValue("margin-"+d));return o?f[e]+(i?l:0):t[e+1][s]-n[s]})).map(t.measure).map(e)}}(V,H,o,j,I),W=G.slideSizes,X=G.slideSizesWithGaps,q=h(V,U,H,C,j,L),J=q.snaps,Y=q.snapsAligned,K=-u(J)+u(X),Q=v(F,K,J,Y,N).snapsContained,Z=!I&&""!==N?Q:Y,$=function(n,e,t){var r,o;return{limit:(r=e[0],o=u(e),a(t?r-n:o,r))}}(K,Z,I).limit,_=s(c(Z),O,I),nn=_.clone(),en=i(o),tn=function(n){var e=0;function t(n,t){return function(){n===!!e&&t()}}function r(){e=window.requestAnimationFrame(n)}return{proceed:t(!0,r),start:t(!1,r),stop:t(!0,(function(){window.cancelAnimationFrame(e),e=0}))}}((function(){I||fn.scrollBounds.constrain(fn.dragHandler.pointerDown()),fn.scrollBody.seek(un).update();var n=fn.scrollBody.settle(un);n&&!fn.dragHandler.pointerDown()&&(fn.animation.stop(),E.emit("settle")),n||E.emit("scroll"),I&&(fn.scrollLooper.loop(fn.scrollBody.direction()),fn.slideLooper.loop()),fn.translate.to(on),fn.animation.proceed()})),rn=Z[_.get()],on=f(rn),un=f(rn),cn=p(on,z,1),an=y(I,Z,K,$,un),sn=function(n,e,t,r,o,i){function u(r){var u=r.distance,c=r.index!==e.get();u&&(n.start(),o.add(u)),c&&(t.set(e.get()),e.set(r.index),i.emit("select"))}return{distance:function(n,e){u(r.byDistance(n,e))},index:function(n,t){var o=e.clone().set(n);u(r.byIndex(o.get(),t))}}}(tn,_,nn,an,un,E),dn=function(n,e,t,r,o,i,u){var c=o.removeOffset,a=o.constrain,s=Math.min(Math.max(u,.01),.99),d=i?[0,e,-e]:[0],f=l(d,s);function l(e,o){var i=e||d,u=o||0,c=t.map((function(n){return n*u}));return i.reduce((function(e,o){var i=r.map((function(e,r){return{start:e-t[r]+c[r]+o,end:e+n-c[r]+o,index:r}}));return e.concat(i)}),[])}return{check:function(n,e){var t=i?c(n):a(n);return(e||f).reduce((function(n,e){var r=e.index,o=e.start,i=e.end;return-1===n.indexOf(r)&&o<t&&i>t?n.concat([r]):n}),[])},findSlideBounds:l}}(F,K,W,J,$,I,B),fn={containerRect:C,slideRects:j,animation:tn,axis:V,direction:R,dragHandler:l(V,R,t,un,D,function(n,t){var r,o;function i(n){return"undefined"!=typeof TouchEvent&&n instanceof TouchEvent}function u(n){return n.timeStamp}function c(e,t){var r="client"+("x"===(t||n.scroll)?"X":"Y");return(i(e)?e.touches[0]:e)[r]}return{isTouchEvent:i,pointerDown:function(n){return r=n,o=n,t.measure(c(n))},pointerMove:function(n){var e=c(n)-c(o),i=u(n)-u(r)>170;return o=n,i&&(r=n),t.measure(e)},pointerUp:function(n){if(!r||!o)return 0;var i=c(o)-c(r),a=u(n)-u(r),s=u(n)-u(o)>170,d=i/a;return a&&!s&&e(d)>.1?t.measure(d):0},readPoint:c}}(V,H),on,tn,sn,cn,an,_,E,I,k),eventStore:d(),pxToPercent:H,index:_,indexPrevious:nn,limit:$,location:on,options:w,scrollBody:cn,scrollBounds:m($,on,un,cn),scrollLooper:g(K,H,$,on,[on,un]),scrollProgress:x($),scrollSnaps:Z,scrollTarget:an,scrollTo:sn,slideLooper:S(V,F,K,X,Z,dn,on,o),slidesInView:dn,slideIndexes:en,target:un,translate:b(V,R,r)};return fn}var E={align:"center",axis:"x",containScroll:"",direction:"ltr",dragFree:!1,draggable:!0,inViewThreshold:0,loop:!1,skipSnaps:!1,slidesToScroll:1,speed:10,startIndex:0};function A(n,e,t){var r,o,i,u,c,a,s,d,f,l=function(){var n={};function e(e){return n[e]||[]}var t={emit:function(n){return e(n).forEach((function(e){return e(n)})),t},off:function(r,o){return n[r]=e(r).filter((function(n){return n!==o})),t},on:function(r,o){return n[r]=e(r).concat([o]),t}};return t}(),p=(r=function(){if(x){var n=u.axis.measureSize(s.getBoundingClientRect());S!==n&&M(),l.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),m=M,v=l.on,g=l.off,x=!1,h=Object.assign({},E,A.globalOptions),y=Object.assign({},h),S=0;function b(){var e,t="container"in n&&n.container,r="slides"in n&&n.slides;s="root"in n?n.root:n,d=t||s.children[0],f=r||[].slice.call(d.children),e=getComputedStyle(s,":before").content,c={get:function(){try{return JSON.parse(e.slice(1,-1).replace(/\\/g,""))}catch(n){}return{}}}}function T(n,e){if(b(),h=Object.assign({},h,n),y=Object.assign({},h,c.get()),a=Object.assign([],e),(u=w(s,d,f,y,l)).eventStore.add(window,"resize",p),u.translate.to(u.location),S=u.axis.measureSize(s.getBoundingClientRect()),a.forEach((function(n){return n.init(z)})),y.loop){if(!u.slideLooper.canLoop())return P(),T({loop:!1},e);u.slideLooper.loop()}y.draggable&&d.offsetParent&&f.length&&u.dragHandler.addActivationEvents(),x||(setTimeout((function(){return l.emit("init")}),0),x=!0)}function M(n,e){if(x){var t=I(),r=Object.assign({startIndex:t},n);P(),T(r,e||a),l.emit("reInit")}}function P(){u.dragHandler.removeAllEvents(),u.animation.stop(),u.eventStore.removeAll(),u.translate.clear(),u.slideLooper.clear(),a.forEach((function(n){return n.destroy()}))}function O(n){var e=u[n?"target":"location"].get(),t=y.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function B(n,e,t){u.scrollBody.useBaseMass().useSpeed(e?100:y.speed),x&&u.scrollTo.index(n,t||0)}function I(){return u.index.get()}var z={canScrollNext:function(){return u.index.clone().add(1).get()!==I()},canScrollPrev:function(){return u.index.clone().add(-1).get()!==I()},clickAllowed:function(){return u.dragHandler.clickAllowed()},containerNode:function(){return d},internalEngine:function(){return u},destroy:function(){x&&(P(),x=!1,l.emit("destroy"))},off:g,on:v,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:m,rootNode:function(){return s},scrollNext:function(n){B(u.index.clone().add(1).get(),!0===n,-1)},scrollPrev:function(n){B(u.index.clone().add(-1).get(),!0===n,1)},scrollProgress:function(){return u.scrollProgress.get(u.location.get())},scrollSnapList:function(){return u.scrollSnaps.map(u.scrollProgress.get)},scrollTo:B,selectedScrollSnap:I,slideNodes:function(){return f},slidesInView:O,slidesNotInView:function(n){var e=O(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}};return T(e,t),z}return A.globalOptions=void 0,A})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarousel=t()}(this,(function(){"use strict";function n(n){return"number"==typeof n}function t(n){return"[object Object]"===Object.prototype.toString.call(n)}function e(n){return t(n)||function(n){return Array.isArray(n)}(n)}function r(n){return Math.abs(n)}function o(n){return n?n/r(n):0}function i(n,t){return r(n-t)}function u(n){return f(n).map(Number)}function c(n){return n[a(n)]}function a(n){return Math.max(0,n.length-1)}function f(n){return Object.keys(n)}function s(n,e){return[n,e].reduce((function(n,e){return f(e).forEach((function(r){var o=n[r],i=e[r],u=t(o)&&t(i);n[r]=u?s(o,i):i})),n}),{})}function d(n,t){var r=f(n),o=f(t);return r.length===o.length&&r.every((function(r){var o=n[r],i=t[r];return"function"==typeof o?"".concat(o)==="".concat(i):e(o)&&e(i)?d(o,i):o===i}))}function l(t,e){var r={start:function(){return 0},center:function(n){return o(n)/2},end:o};function o(n){return e-n}return{measure:function(o){return n(t)?e*Number(t):r[t](o)}}}function p(n,t){var e=r(n-t);function o(t){return t<n}function i(n){return n>t}function u(n){return o(n)||i(n)}return{length:e,max:t,min:n,constrain:function(e){return u(e)?o(e)?n:t:e},reachedAny:u,reachedMax:i,reachedMin:o,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function v(n,t,e){var o=p(0,n),i=o.min,u=o.constrain,c=n+1,a=f(t);function f(n){return e?r((c+n)%c):u(n)}function s(){return a}function d(n){return a=f(n),l}var l={add:function(n){return d(s()+n)},clone:function(){return v(n,s(),e)},get:s,set:d,min:i,max:n};return l}function m(){var n=[];var t={add:function(e,r,o,i){return void 0===i&&(i=!1),e.addEventListener(r,o,i),n.push((function(){return e.removeEventListener(r,o,i)})),t},removeAll:function(){return n=n.filter((function(n){return n()})),t}};return t}function g(t){var e=t;function r(n){return e/=n,i}function o(t){return n(t)?t:t.get()}var i={add:function(n){return e+=o(n),i},divide:r,get:function(){return e},multiply:function(n){return e*=n,i},normalize:function(){return 0!==e&&r(e),i},set:function(n){return e=o(n),i},subtract:function(n){return e-=o(n),i}};return i}function x(n,t,e,u,c,a,f,s,d,l,p,v,x,h,y,S){var b=n.cross,w=["INPUT","SELECT","TEXTAREA"],E=g(0),A=m(),M=m(),T=x.measure(20),O={mouse:300,touch:400},B={mouse:500,touch:600},P=y?5:16,k=0,I=0,z=!1,D=!1,L=!1,N=!1;function C(n){if(!(N="mousedown"===n.type)||0===n.button){var t,r,o=i(u.get(),a.get())>=2,f=N||!o,s=(t=n.target,r=t.nodeName||"",!(w.indexOf(r)>-1)),l=o||N&&s;z=!0,c.pointerDown(n),E.set(u),u.set(a),d.useBaseMass().useSpeed(80),function(){var n=N?document:e;M.add(n,"touchmove",V).add(n,"touchend",H).add(n,"mousemove",V).add(n,"mouseup",H)}(),k=c.readPoint(n),I=c.readPoint(n,b),v.emit("pointerDown"),f&&(L=!1),l&&n.preventDefault()}}function V(n){if(!D&&!N){if(!n.cancelable)return H(n);var e=c.readPoint(n),r=c.readPoint(n,b),o=i(e,k),a=i(r,I);if(!(D=o>a)&&!L)return H(n)}var s=c.pointerMove(n);!L&&s&&(L=!0),f.start(),u.add(t.apply(s)),n.preventDefault()}function H(n){var e=l.byDistance(0,!1).index!==p.get(),a=c.pointerUp(n)*(y?B:O)[N?"mouse":"touch"],f=function(n,t){var e=p.clone().add(-1*o(n)),i=e.get()===p.min||e.get()===p.max,u=l.byDistance(n,!y).distance;return y||r(n)<T?u:!h&&i?.4*u:S&&t?.5*u:l.byIndex(e.get(),0).distance}(t.apply(a),e),m=function(n,t){if(0===n||0===t)return 0;if(r(n)<=r(t))return 0;var e=i(r(n),r(t));return r(e/n)}(a,f),g=i(u.get(),E.get())>=.5,x=e&&m>.75,b=r(a)<T,w=x?10:P,A=x?1+2.5*m:1;g&&!N&&(L=!0),D=!1,z=!1,M.removeAll(),d.useSpeed(b?9:w).useMass(A),s.distance(f,!y),N=!1,v.emit("pointerUp")}function R(n){L&&n.preventDefault()}return{addActivationEvents:function(){var n=e;A.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",C).add(n,"mousedown",C).add(n,"touchcancel",H).add(n,"contextmenu",H).add(n,"click",R)},clickAllowed:function(){return!L},pointerDown:function(){return z},removeAllEvents:function(){A.removeAll(),M.removeAll()}}}function h(n,t,e){var r,i,u=(r=2,i=Math.pow(10,r),function(n){return Math.round(n*i)/i}),c=g(0),a=g(0),f=g(0),s=0,d=t,l=e;function p(n){return d=n,m}function v(n){return l=n,m}var m={direction:function(){return s},seek:function(t){f.set(t).subtract(n);var e,r,i,u,p=(e=f.get(),(i=0)+(e-(r=0))/(100-r)*(d-i));return s=o(f.get()),f.normalize().multiply(p).subtract(c),(u=f).divide(l),a.add(u),m},settle:function(t){var e=t.get()-n.get(),r=!u(e);return r&&n.set(t),r},update:function(){c.add(a),n.add(c),a.multiply(0)},useBaseMass:function(){return v(e)},useBaseSpeed:function(){return p(t)},useMass:v,useSpeed:p};return m}function y(n,t,e,o,i){var u=i.measure(10),c=i.measure(50),a=!1;return{constrain:function(i){if(!a&&n.reachedAny(e.get())&&n.reachedAny(t.get())){var f=n.reachedMin(t.get())?"min":"max",s=r(n[f]-t.get()),d=e.get()-t.get(),l=Math.min(s/c,.85);e.subtract(d*l),!i&&r(d)<u&&(e.set(n.constrain(e.get())),o.useSpeed(10).useMass(3))}},toggleActive:function(n){a=!n}}}function S(n,t,e,r){var o=p(-t+n,e[0]),i=e.map(o.constrain);return{snapsContained:function(){if(t<=n)return[o.max];if("keepSnaps"===r)return i;var e=function(){var n=i[0],t=c(i),e=i.lastIndexOf(n),r=i.indexOf(t)+1;return p(e,r)}(),u=e.min,a=e.max;return i.slice(u,a)}()}}function b(n,t,e,r){var o=p(t.min+.1,t.max+.1),i=o.reachedMin,u=o.reachedMax;return{loop:function(t){if(function(n){return 1===n?u(e.get()):-1===n&&i(e.get())}(t)){var o=n*(-1*t);r.forEach((function(n){return n.add(o)}))}}}}function w(n){var t=n.max,e=n.length;return{get:function(n){return(n-t)/-e}}}function E(n,t,e,o,i){var u=o.reachedAny,c=o.removeOffset,a=o.constrain;function f(n,t){return r(n)<r(t)?n:t}function s(t,o){var i=t,u=t+e,c=t-e;return n?o?r(f(i,1===o?u:c))*o:f(f(i,u),c):i}return{byDistance:function(e,o){var f=i.get()+e,d=function(e){var o=n?c(e):a(e);return{index:t.map((function(n){return n-o})).map((function(n){return s(n,0)})).map((function(n,t){return{diff:n,index:t}})).sort((function(n,t){return r(n.diff)-r(t.diff)}))[0].index,distance:o}}(f),l=d.index,p=d.distance,v=!n&&u(f);return!o||v?{index:l,distance:e}:{index:l,distance:e+s(t[l]-p,0)}},byIndex:function(n,e){return{index:n,distance:s(t[n]-i.get(),e)}},shortcut:s}}function A(n,t,e){var r="x"===n.scroll?function(n){return"translate3d(".concat(n,"px,0px,0px)")}:function(n){return"translate3d(0px,".concat(n,"px,0px)")},o=e.style,i=!1;return{clear:function(){i||(o.transform="",e.getAttribute("style")||e.removeAttribute("style"))},to:function(n){i||(o.transform=r(t.apply(n.get())))},toggleActive:function(n){i=!n}}}function M(n,t,e,r,o,i,c,a,f){var s,d=u(o),l=u(o).reverse(),p=(s=i[0]-1,x(m(l,s),"end")).concat(function(){var n=e-i[0]-1;return x(m(d,n),"start")}());function v(n,t){return n.reduce((function(n,t){return n-o[t]}),t)}function m(n,t){return n.reduce((function(n,e){return v(n,t)>0?n.concat([e]):n}),[])}function x(e,o){var i="start"===o,u=i?-r:r,s=c.findSlideBounds([u]);return e.map((function(e){var o=i?0:-r,u=i?r:0,c=s.filter((function(n){return n.index===e}))[0][i?"end":"start"],d=g(-1),l=g(-1),p=A(n,t,f[e]);return{index:e,location:l,translate:p,target:function(){return d.set(a.get()>c?o:u)}}}))}return{canLoop:function(){return p.every((function(n){var t=n.index;return v(d.filter((function(n){return n!==t})),e)<=0}))},clear:function(){p.forEach((function(n){return n.translate.clear()}))},loop:function(){p.forEach((function(n){var t=n.target,e=n.translate,r=n.location,o=t();o.get()!==r.get()&&(0===o.get()?e.clear():e.to(o),r.set(o))}))},loopPoints:p}}function T(n,t,e,r,o,i,u){var c=o.removeOffset,a=o.constrain,f=i?[0,t,-t]:[0],s=d(f,u);function d(t,o){var i=t||f,u=function(n){var t=n||0;return e.map((function(n){return p(.5,n-.5).constrain(n*t)}))}(o);return i.reduce((function(t,o){var i=r.map((function(t,r){return{start:t-e[r]+u[r]+o,end:t+n-u[r]+o,index:r}}));return t.concat(i)}),[])}return{check:function(n,t){var e=i?c(n):a(n);return(t||s).reduce((function(n,t){var r=t.index,o=t.start,i=t.end;return!(-1!==n.indexOf(r))&&(o<e&&i>e)?n.concat([r]):n}),[])},findSlideBounds:d}}function O(t,e,r){var o=n(r);return{groupSlides:function(n){return o?function(n,t){return u(n).filter((function(n){return n%t==0})).map((function(e){return n.slice(e,e+t)}))}(n,r):function(n){return u(n).reduce((function(n,r){var o=e.slice(c(n),r+1).reduce((function(n,t){return n+t}),0);return!r||o>t?n.concat(r):n}),[]).map((function(t,e,r){return n.slice(t,r[e+1])}))}(n)}}}function B(n,t,e,o,i){var f=o.align,s=o.axis,d=o.direction,B=o.startIndex,P=o.inViewThreshold,k=o.loop,I=o.speed,z=o.dragFree,D=o.slidesToScroll,L=o.skipSnaps,N=o.containScroll,C=t.getBoundingClientRect(),V=e.map((function(n){return n.getBoundingClientRect()})),H=function(n){var t="rtl"===n?-1:1;return{apply:function(n){return n*t}}}(d),R=function(n,t){var e="y"===n?"y":"x";return{scroll:e,cross:"y"===n?"x":"y",startEdge:"y"===e?"top":"rtl"===t?"right":"left",endEdge:"y"===e?"bottom":"rtl"===t?"left":"right",measureSize:function(n){var t=n.width,r=n.height;return"x"===e?t:r}}}(s,d),j=R.measureSize(C),F=function(n){return{measure:function(t){return n*(t/100)}}}(j),q=l(f,j),U=!k&&""!==N,G=function(n,t,e,o,i){var u=n.measureSize,f=n.startEdge,s=n.endEdge,d=function(){if(!i)return 0;var n=e[0];return r(t[f]-n[f])}(),l=function(){if(!i)return 0;var n=window.getComputedStyle(c(o));return parseFloat(n.getPropertyValue("margin-".concat(s)))}(),p=e.map(u),v=e.map((function(n,t,e){var r=!t,o=t===a(e);return r?p[t]+d:o?p[t]+l:e[t+1][f]-n[f]})).map(r);return{slideSizes:p,slideSizesWithGaps:v}}(R,C,V,e,k||""!==N),J=G.slideSizes,W=G.slideSizesWithGaps,X=O(j,W,D),Y=function(n,t,e,o,i,u,f){var s,d=n.startEdge,l=n.endEdge,p=u.groupSlides,v=p(o).map((function(n){return c(n)[l]-n[0][d]})).map(r).map(t.measure),m=o.map((function(n){return e[d]-n[d]})).map((function(n){return-r(n)})),g=(s=c(m)-c(i),p(m).map((function(n){return n[0]})).map((function(n,t,e){var r=!t,o=t===a(e);return f&&r?0:f&&o?s:n+v[t]})));return{snaps:m,snapsAligned:g}}(R,q,C,V,W,X,U),K=Y.snaps,Q=Y.snapsAligned,Z=-c(K)+c(W),$=S(j,Z,Q,N).snapsContained,_=U?$:Q,nn=function(n,t,e){var r,o;return{limit:(r=t[0],o=c(t),p(e?r-n:o,r))}}(Z,_,k).limit,tn=v(a(_),B,k),en=tn.clone(),rn=u(e),on=function(n){var t=0;function e(n,e){return function(){n===!!t&&e()}}function r(){t=window.requestAnimationFrame(n)}return{proceed:e(!0,r),start:e(!1,r),stop:e(!0,(function(){window.cancelAnimationFrame(t),t=0}))}}((function(){k||vn.scrollBounds.constrain(vn.dragHandler.pointerDown()),vn.scrollBody.seek(an).update();var n=vn.scrollBody.settle(an);n&&!vn.dragHandler.pointerDown()&&(vn.animation.stop(),i.emit("settle")),n||i.emit("scroll"),k&&(vn.scrollLooper.loop(vn.scrollBody.direction()),vn.slideLooper.loop()),vn.translate.to(cn),vn.animation.proceed()})),un=_[tn.get()],cn=g(un),an=g(un),fn=h(cn,I,1),sn=E(k,_,Z,nn,an),dn=function(n,t,e,r,o,i){function u(r){var u=r.distance,c=r.index!==t.get();u&&(n.start(),o.add(u)),c&&(e.set(t.get()),t.set(r.index),i.emit("select"))}return{distance:function(n,t){u(r.byDistance(n,t))},index:function(n,e){var o=t.clone().set(n);u(r.byIndex(o.get(),e))}}}(on,tn,en,sn,an,i),ln=T(j,Z,J,K,nn,k,P),pn=x(R,H,n,an,function(n){var t,e;function o(n){return"undefined"!=typeof TouchEvent&&n instanceof TouchEvent}function i(n){return n.timeStamp}function u(t,e){var r=e||n.scroll,i="client".concat("x"===r?"X":"Y");return(o(t)?t.touches[0]:t)[i]}return{isTouchEvent:o,pointerDown:function(n){return t=n,e=n,u(n)},pointerMove:function(n){var r=u(n)-u(e),o=i(n)-i(t)>170;return e=n,o&&(t=n),r},pointerUp:function(n){if(!t||!e)return 0;var o=u(e)-u(t),c=i(n)-i(t),a=i(n)-i(e)>170,f=o/c;return c&&!a&&r(f)>.1?f:0},readPoint:u}}(R),cn,on,dn,fn,sn,tn,i,F,k,z,L),vn={containerRect:C,slideRects:V,animation:on,axis:R,direction:H,dragHandler:pn,eventStore:m(),percentOfView:F,index:tn,indexPrevious:en,limit:nn,location:cn,options:o,scrollBody:fn,scrollBounds:y(nn,cn,an,fn,F),scrollLooper:b(Z,nn,cn,[cn,an]),scrollProgress:w(nn),scrollSnaps:_,scrollTarget:sn,scrollTo:dn,slideLooper:M(R,H,j,Z,W,_,ln,cn,e),slidesToScroll:X,slidesInView:ln,slideIndexes:rn,target:an,translate:A(R,H,t)};return vn}var P={align:"center",axis:"x",containScroll:"",direction:"ltr",slidesToScroll:1,breakpoints:{},dragFree:!1,draggable:!0,inViewThreshold:0,loop:!1,skipSnaps:!1,speed:10,startIndex:0,active:!0};function k(){function n(n,t){return s(n,t||{})}return{merge:n,areEqual:function(n,t){return JSON.stringify(f(n.breakpoints||{}))===JSON.stringify(f(t.breakpoints||{}))&&d(n,t)},atMedia:function(t){var e=t.breakpoints||{},r=f(e).filter((function(n){return window.matchMedia(n).matches})).map((function(n){return e[n]})).reduce((function(t,e){return n(t,e)}),{});return n(t,r)}}}function I(n,t,e){var r,o,i,u,c,a=m(),f=k(),s=function(){var n,t=k(),e=t.atMedia,r=t.areEqual,o=[];function i(n){var t=e(n.options);return function(){return!r(t,e(n.options))}}var u={init:function(t,r){return o=t.map(i),(n=t.filter((function(n){return e(n.options).active}))).forEach((function(n){return n.init(r)})),t.reduce((function(n,t){var e;return Object.assign(n,((e={})[t.name]=t,e))}),{})},destroy:function(){n=n.filter((function(n){return n.destroy()}))},haveChanged:function(){return o.some((function(n){return n()}))}};return u}(),d=function(){var n={};function t(t){return n[t]||[]}var e={emit:function(n){return t(n).forEach((function(t){return t(n)})),e},off:function(r,o){return n[r]=t(r).filter((function(n){return n!==o})),e},on:function(r,o){return n[r]=t(r).concat([o]),e}};return e}(),l=d.on,p=d.off,v=w,g=!1,x=f.merge(P,I.globalOptions),h=f.merge(x),y=[],S=0;function b(t,e){if(!g){var a,l;if(a="container"in n&&n.container,l="slides"in n&&n.slides,i="root"in n?n.root:n,u=a||i.children[0],c=l||[].slice.call(u.children),x=f.merge(x,t),h=f.atMedia(x),r=B(i,u,c,h,d),S=r.axis.measureSize(i.getBoundingClientRect()),!h.active)return E();if(r.translate.to(r.location),y=e||y,o=s.init(y,O),h.loop){if(!r.slideLooper.canLoop())return E(),b({loop:!1},e);r.slideLooper.loop()}h.draggable&&u.offsetParent&&c.length&&r.dragHandler.addActivationEvents()}}function w(n,t){var e=T();E(),b(f.merge({startIndex:e},n),t),d.emit("reInit")}function E(){r.dragHandler.removeAllEvents(),r.animation.stop(),r.eventStore.removeAll(),r.translate.clear(),r.slideLooper.clear(),s.destroy()}function A(n){var t=r[n?"target":"location"].get(),e=h.loop?"removeOffset":"constrain";return r.slidesInView.check(r.limit[e](t))}function M(n,t,e){h.active&&!g&&(r.scrollBody.useBaseMass().useSpeed(t?100:h.speed),r.scrollTo.index(n,e||0))}function T(){return r.index.get()}var O={canScrollNext:function(){return r.index.clone().add(1).get()!==T()},canScrollPrev:function(){return r.index.clone().add(-1).get()!==T()},clickAllowed:function(){return r.dragHandler.clickAllowed()},containerNode:function(){return u},internalEngine:function(){return r},destroy:function(){g||(g=!0,a.removeAll(),E(),d.emit("destroy"))},off:p,on:l,plugins:function(){return o},previousScrollSnap:function(){return r.indexPrevious.get()},reInit:v,rootNode:function(){return i},scrollNext:function(n){M(r.index.clone().add(1).get(),!0===n,-1)},scrollPrev:function(n){M(r.index.clone().add(-1).get(),!0===n,1)},scrollProgress:function(){return r.scrollProgress.get(r.location.get())},scrollSnapList:function(){return r.scrollSnaps.map(r.scrollProgress.get)},scrollTo:M,selectedScrollSnap:T,slideNodes:function(){return c},slidesInView:A,slidesNotInView:function(n){var t=A(n);return r.slideIndexes.filter((function(n){return-1===t.indexOf(n)}))}};return b(t,e),a.add(window,"resize",(function(){var n=f.atMedia(x),t=!f.areEqual(n,h),e=r.axis.measureSize(i.getBoundingClientRect()),o=S!==e,u=s.haveChanged();(o||t||u)&&w(),d.emit("resize")})),setTimeout((function(){return d.emit("init")}),0),O}return I.globalOptions=void 0,I.optionsHandler=k,I})); |
export { EmblaOptionsType } from './components/Options'; | ||
export { EmblaEventType } from './components/EventEmitter'; | ||
export { EmblaCarouselType, EmblaPluginType } from './components'; | ||
export { EmblaEventType } from './components/EventHandler'; | ||
export { EmblaPluginType } from './components/Plugins'; | ||
export { EmblaCarouselType } from './components'; | ||
export { default } from './components'; |
{ | ||
"name": "embla-carousel", | ||
"version": "6.2.0", | ||
"author": "David Cetinkaya", | ||
"version": "7.0.0-rc01", | ||
"author": "David Jerleke", | ||
"description": "A lightweight carousel library with fluid motion and great swipe precision", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/davidcetinkaya/embla-carousel" | ||
"url": "git+https://github.com/davidjerleke/embla-carousel" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/davidcetinkaya/embla-carousel/issues" | ||
"url": "https://github.com/davidjerleke/embla-carousel/issues" | ||
}, | ||
@@ -26,5 +26,6 @@ "homepage": "https://www.embla-carousel.com", | ||
], | ||
"main": "embla-carousel.umd.js", | ||
"unpkg": "embla-carousel.umd.js", | ||
"main": "embla-carousel.cjs.js", | ||
"module": "embla-carousel.esm.js", | ||
"browser": "embla-carousel.umd.js", | ||
"types": "index.d.ts", | ||
@@ -45,14 +46,18 @@ "sideEffects": false, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"eslint": "^7.24.0", | ||
"eslint-config-prettier": "^8.2.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.45.2", | ||
"ts-jest": "^26.5.5", | ||
"typescript": "^4.2.4" | ||
"@types/jest": "^27.4.0", | ||
"@typescript-eslint/eslint-plugin": "^5.10.2", | ||
"@typescript-eslint/parser": "^5.10.2", | ||
"embla-carousel-auto-height": "7.0.0-rc01", | ||
"embla-carousel-autoplay": "7.0.0-rc01", | ||
"embla-carousel-class-names": "7.0.0-rc01", | ||
"embla-carousel-wheel-gestures": "2.2.0", | ||
"eslint": "^8.8.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"jest": "^27.5.0", | ||
"prettier": "2.5.1", | ||
"rollup": "^2.68.0", | ||
"ts-jest": "^27.1.3", | ||
"typescript": "^4.5.5" | ||
} | ||
} |
@@ -11,3 +11,3 @@ <br /> | ||
<a href="https://www.npmjs.com/package/embla-carousel"><img src="https://img.shields.io/npm/v/embla-carousel.svg?color=%23c1a8e2"></a> | ||
<a href="https://github.com/davidcetinkaya/embla-carousel/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://img.shields.io/github/workflow/status/davidcetinkaya/embla-carousel/Continuous%20Integration?color=%238ab4f8"></a> | ||
<a href="https://github.com/davidjerleke/embla-carousel/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://img.shields.io/github/workflow/status/davidjerleke/embla-carousel/Continuous%20Integration?color=%238ab4f8"></a> | ||
<a href="https://prettier.io"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat&color=%23c1a8e2"></a> | ||
@@ -78,3 +78,3 @@ <a href="https://bundlephobia.com/result?p=embla-carousel@latest"><img src="https://img.shields.io/bundlephobia/minzip/embla-carousel?color=%238ab4f8&label=gzip%20size"> | ||
<p align="center"> | ||
Thank you to all contributors for making <a href="https://www.embla-carousel.com/">Embla Carousel</a> awesome! <a href="https://github.com/davidcetinkaya/embla-carousel/blob/master/.github/CONTRIBUTING.md">Contributions</a> are welcome. | ||
Thank you to all contributors for making <a href="https://www.embla-carousel.com/">Embla Carousel</a> awesome! <a href="https://github.com/davidjerleke/embla-carousel/blob/master/.github/CONTRIBUTING.md">Contributions</a> are welcome. | ||
</p> | ||
@@ -122,4 +122,4 @@ <p align="center"> | ||
<p align="center"> | ||
<sup>Copyright © 2019-present, David Cetinkaya.</sup><br> | ||
Embla is <a href="https://github.com/davidcetinkaya/embla-carousel/blob/master/LICENSE">MIT licensed</a> 💖. | ||
<sup>Copyright © 2019-present, David Jerleke.</sup><br> | ||
Embla is <a href="https://github.com/davidjerleke/embla-carousel/blob/master/LICENSE">MIT licensed</a> 💖. | ||
</p> | ||
@@ -126,0 +126,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
384155
41
3220
15
1
2