embla-carousel
Advanced tools
Comparing version 8.0.0-rc02 to 8.0.0-rc03
import { EngineType } from './Engine'; | ||
type AnimationCallbackType = (engine: EngineType) => void; | ||
export type AnimationUpdateType = (engine: EngineType) => void; | ||
export type AnimationRenderType = (engine: EngineType, lagFactor: number) => void; | ||
export type AnimationType = { | ||
@@ -9,3 +10,2 @@ init: (engineInstance: EngineType) => void; | ||
}; | ||
export declare function Animation(update: AnimationCallbackType, draw: AnimationCallbackType): AnimationType; | ||
export {}; | ||
export declare function Animation(update: AnimationUpdateType, render: AnimationRenderType): AnimationType; |
@@ -20,3 +20,3 @@ import { EmblaCarouselType } from './EmblaCarousel'; | ||
}; | ||
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, dragFree: boolean, skipSnaps: boolean, baseFriction: number): 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, dragFree: boolean, dragThreshold: number, skipSnaps: boolean, baseFriction: number): DragHandlerType; | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
import { AnimationType } from './Animation'; | ||
import { AxisType } from './Axis'; | ||
@@ -24,2 +23,3 @@ import { CounterType } from './Counter'; | ||
import { Vector1DType } from './Vector1d'; | ||
import { AnimationType } from './Animation'; | ||
export type EngineType = { | ||
@@ -26,0 +26,0 @@ eventHandler: EventHandlerType; |
@@ -27,2 +27,3 @@ import { AlignmentOptionType } from './Alignment'; | ||
dragFree: boolean; | ||
dragThreshold: number; | ||
inViewThreshold: number; | ||
@@ -29,0 +30,0 @@ loop: boolean; |
import { Vector1DType } from './Vector1d'; | ||
export type ScrollBodyType = { | ||
direction: () => number; | ||
seek: (target: Vector1DType) => ScrollBodyType; | ||
settle: (target: Vector1DType) => boolean; | ||
seek: () => ScrollBodyType; | ||
settled: () => boolean; | ||
useBaseFriction: () => ScrollBodyType; | ||
@@ -10,3 +10,4 @@ useBaseDuration: () => ScrollBodyType; | ||
useDuration: (n: number) => ScrollBodyType; | ||
velocity: () => number; | ||
}; | ||
export declare function ScrollBody(location: Vector1DType, baseDuration: number, baseFriction: number): ScrollBodyType; | ||
export declare function ScrollBody(location: Vector1DType, target: Vector1DType, baseDuration: number, baseFriction: number): ScrollBodyType; |
@@ -10,3 +10,3 @@ import { AxisType } from './Axis'; | ||
location: Vector1DType; | ||
target: () => Vector1DType; | ||
target: () => number; | ||
}; | ||
@@ -13,0 +13,0 @@ export type SlideLooperType = { |
import { AxisType } from './Axis'; | ||
import { DirectionType } from './Direction'; | ||
import { Vector1DType } from './Vector1d'; | ||
export type TranslateType = { | ||
clear: () => void; | ||
to: (vector: Vector1DType) => void; | ||
to: (target: number) => void; | ||
toggleActive: (active: boolean) => void; | ||
}; | ||
export declare function Translate(axis: AxisType, direction: DirectionType, container: HTMLElement): TranslateType; |
@@ -11,3 +11,2 @@ import { PointerEventType } from './DragTracker'; | ||
export declare function factorAbs(valueB: number, valueA: number): number; | ||
export declare function roundToDecimals(decimalPoints: number): (n: number) => number; | ||
export declare function arrayKeys<Type>(array: Type[]): number[]; | ||
@@ -14,0 +13,0 @@ export declare function arrayLast<Type>(array: Type[]): Type; |
export type Vector1DType = { | ||
get: () => number; | ||
set: (v: Vector1DType | number) => Vector1DType; | ||
add: (v: Vector1DType | number) => Vector1DType; | ||
subtract: (v: Vector1DType | number) => Vector1DType; | ||
multiply: (n: number) => Vector1DType; | ||
divide: (n: number) => Vector1DType; | ||
normalize: () => Vector1DType; | ||
set: (n: Vector1DType | number) => void; | ||
add: (n: Vector1DType | number) => void; | ||
subtract: (n: Vector1DType | number) => void; | ||
}; | ||
export declare function Vector1D(value: number): Vector1DType; | ||
export declare function Vector1D(initialValue: number): Vector1DType; |
@@ -33,6 +33,2 @@ 'use strict'; | ||
} | ||
function roundToDecimals(decimalPoints) { | ||
const pow = Math.pow(10, decimalPoints); | ||
return n => Math.round(n * pow) / pow; | ||
} | ||
function arrayKeys(array) { | ||
@@ -90,74 +86,2 @@ return objectKeys(array).map(Number); | ||
function EventStore() { | ||
let listeners = []; | ||
function add(node, type, handler, options = { | ||
passive: true | ||
}) { | ||
node.addEventListener(type, handler, options); | ||
listeners.push(() => node.removeEventListener(type, handler, options)); | ||
return self; | ||
} | ||
function clear() { | ||
listeners = listeners.filter(remove => remove()); | ||
} | ||
const self = { | ||
add, | ||
clear | ||
}; | ||
return self; | ||
} | ||
function Animation(update, draw) { | ||
const documentVisibleHandler = EventStore(); | ||
const timeStep = 1000 / 60; | ||
let lastTimeStamp = null; | ||
let delta = 0; | ||
let animationFrame = 0; | ||
let engine; | ||
function init(engineInstance) { | ||
engine = engineInstance; | ||
documentVisibleHandler.add(document, 'visibilitychange', () => { | ||
if (document.hidden) lastTimeStamp = null; | ||
}); | ||
} | ||
function destroy() { | ||
stop(); | ||
documentVisibleHandler.clear(); | ||
} | ||
function ifAnimating(active, cb) { | ||
return () => { | ||
if (active === !!animationFrame) cb(); | ||
}; | ||
} | ||
function animate(timeStamp) { | ||
if (!lastTimeStamp) { | ||
lastTimeStamp = timeStamp; | ||
return start(); | ||
} | ||
delta += timeStamp - lastTimeStamp; | ||
lastTimeStamp = timeStamp; | ||
while (delta >= timeStep) { | ||
update(engine); | ||
delta -= timeStep; | ||
} | ||
draw(engine); | ||
if (animationFrame) start(); | ||
} | ||
function start() { | ||
animationFrame = window.requestAnimationFrame(animate); | ||
} | ||
function stop() { | ||
window.cancelAnimationFrame(animationFrame); | ||
lastTimeStamp = null; | ||
animationFrame = 0; | ||
} | ||
const self = { | ||
init, | ||
destroy, | ||
start: ifAnimating(false, start), | ||
stop: ifAnimating(true, stop) | ||
}; | ||
return self; | ||
} | ||
function Axis(axis, direction) { | ||
@@ -270,42 +194,17 @@ const scroll = axis === 'y' ? 'y' : 'x'; | ||
function Vector1D(value) { | ||
let vector = value; | ||
function get() { | ||
return vector; | ||
} | ||
function set(n) { | ||
vector = readNumber(n); | ||
function EventStore() { | ||
let listeners = []; | ||
function add(node, type, handler, options = { | ||
passive: true | ||
}) { | ||
node.addEventListener(type, handler, options); | ||
listeners.push(() => node.removeEventListener(type, handler, options)); | ||
return self; | ||
} | ||
function add(n) { | ||
vector += readNumber(n); | ||
return self; | ||
function clear() { | ||
listeners = listeners.filter(remove => remove()); | ||
} | ||
function subtract(n) { | ||
vector -= readNumber(n); | ||
return self; | ||
} | ||
function multiply(n) { | ||
vector *= n; | ||
return self; | ||
} | ||
function divide(n) { | ||
vector /= n; | ||
return self; | ||
} | ||
function normalize() { | ||
if (vector !== 0) divide(vector); | ||
return self; | ||
} | ||
function readNumber(n) { | ||
return isNumber(n) ? n : n.get(); | ||
} | ||
const self = { | ||
add, | ||
divide, | ||
get, | ||
multiply, | ||
normalize, | ||
set, | ||
subtract | ||
clear | ||
}; | ||
@@ -315,3 +214,3 @@ return self; | ||
function DragHandler(axis, direction, rootNode, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, skipSnaps, baseFriction) { | ||
function DragHandler(axis, direction, rootNode, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction) { | ||
const { | ||
@@ -324,3 +223,2 @@ cross: crossAxis | ||
}; | ||
const dragStartPoint = Vector1D(0); | ||
const initEvents = EventStore(); | ||
@@ -386,3 +284,2 @@ const dragEvents = EventStore(); | ||
dragTracker.pointerDown(evt); | ||
dragStartPoint.set(target); | ||
scrollBody.useFriction(0).useDuration(0); | ||
@@ -396,8 +293,8 @@ target.set(location); | ||
function move(evt) { | ||
const lastScroll = dragTracker.readPoint(evt); | ||
const lastCross = dragTracker.readPoint(evt, crossAxis); | ||
const diffScroll = deltaAbs(lastScroll, startScroll); | ||
const diffCross = deltaAbs(lastCross, startCross); | ||
if (!preventScroll && !isMouse) { | ||
if (!evt.cancelable) return up(evt); | ||
const lastScroll = dragTracker.readPoint(evt); | ||
const lastCross = dragTracker.readPoint(evt, crossAxis); | ||
const diffScroll = deltaAbs(lastScroll, startScroll); | ||
const diffCross = deltaAbs(lastCross, startCross); | ||
preventScroll = diffScroll > diffCross; | ||
@@ -407,3 +304,3 @@ if (!preventScroll) return up(evt); | ||
const diff = dragTracker.pointerMove(evt); | ||
if (diff) preventClick = true; | ||
if (diffScroll > dragThreshold) preventClick = true; | ||
scrollBody.useFriction(0.3).useDuration(1); | ||
@@ -544,30 +441,32 @@ animation.start(); | ||
function ScrollBody(location, baseDuration, baseFriction) { | ||
const roundToTwoDecimals = roundToDecimals(2); | ||
const attraction = Vector1D(0); | ||
let attractionDirection = 0; | ||
function ScrollBody(location, target, baseDuration, baseFriction) { | ||
let hasSettled = true; | ||
let bodyVelocity = 0; | ||
let scrollDirection = 0; | ||
let duration = baseDuration; | ||
let friction = baseFriction; | ||
function seek(target) { | ||
function seek() { | ||
const diff = target.get() - location.get(); | ||
const isInstant = !friction || !duration; | ||
if (isInstant) { | ||
attraction.set(0); | ||
bodyVelocity = 0; | ||
location.set(target); | ||
} else { | ||
attraction.add(diff / duration); | ||
attraction.multiply(friction); | ||
location.add(attraction); | ||
bodyVelocity += diff / duration; | ||
bodyVelocity *= friction; | ||
location.add(bodyVelocity); | ||
} | ||
attractionDirection = mathSign(attraction.get() || diff); | ||
scrollDirection = mathSign(bodyVelocity || diff); | ||
hasSettled = mathAbs(diff) < 0.001; | ||
return self; | ||
} | ||
function settle(target) { | ||
const diff = target.get() - location.get(); | ||
const hasSettled = !roundToTwoDecimals(diff); | ||
function settled() { | ||
if (hasSettled) location.set(target); | ||
return hasSettled; | ||
} | ||
function velocity() { | ||
return bodyVelocity; | ||
} | ||
function direction() { | ||
return attractionDirection; | ||
return scrollDirection; | ||
} | ||
@@ -591,7 +490,8 @@ function useBaseDuration() { | ||
seek, | ||
settle, | ||
settled, | ||
useBaseFriction, | ||
useBaseDuration, | ||
useFriction, | ||
useDuration | ||
useDuration, | ||
velocity | ||
}; | ||
@@ -843,2 +743,28 @@ return self; | ||
function Vector1D(initialValue) { | ||
let value = initialValue; | ||
function get() { | ||
return value; | ||
} | ||
function set(n) { | ||
value = normalizeInput(n); | ||
} | ||
function add(n) { | ||
value += normalizeInput(n); | ||
} | ||
function subtract(n) { | ||
value -= normalizeInput(n); | ||
} | ||
function normalizeInput(n) { | ||
return isNumber(n) ? n : n.get(); | ||
} | ||
const self = { | ||
get, | ||
set, | ||
add, | ||
subtract | ||
}; | ||
return self; | ||
} | ||
function Translate(axis, direction, container) { | ||
@@ -856,3 +782,3 @@ const translate = axis.scroll === 'x' ? x : y; | ||
if (disabled) return; | ||
containerStyle.transform = translate(direction.apply(target.get())); | ||
containerStyle.transform = translate(direction.apply(target)); | ||
} | ||
@@ -899,6 +825,5 @@ function toggleActive(active) { | ||
const point = bounds[isStartEdge ? 'end' : 'start']; | ||
const shift = Vector1D(-1); | ||
const location = Vector1D(-1); | ||
const translate = Translate(axis, direction, slides[index]); | ||
const target = () => shift.set(scroll.get() > point ? initial : altered); | ||
const target = () => scroll.get() > point ? initial : altered; | ||
return { | ||
@@ -938,4 +863,4 @@ index, | ||
const shift = target(); | ||
if (shift.get() === location.get()) return; | ||
if (shift.get() === 0) translate.clear();else translate.to(shift); | ||
if (shift === location.get()) return; | ||
translate.to(shift); | ||
location.set(shift); | ||
@@ -1097,2 +1022,60 @@ }); | ||
function Animation(update, render) { | ||
const documentVisibleHandler = EventStore(); | ||
const timeStep = 1000 / 60; | ||
let lastTimeStamp = null; | ||
let lag = 0; | ||
let animationFrame = 0; | ||
let engine; | ||
function init(engineInstance) { | ||
engine = engineInstance; | ||
documentVisibleHandler.add(document, 'visibilitychange', () => { | ||
if (document.hidden) { | ||
lastTimeStamp = null; | ||
lag = 0; | ||
} | ||
}); | ||
} | ||
function destroy() { | ||
stop(); | ||
documentVisibleHandler.clear(); | ||
} | ||
function ifAnimating(active, cb) { | ||
return () => { | ||
if (active === !!animationFrame) cb(); | ||
}; | ||
} | ||
function animate(timeStamp) { | ||
if (!lastTimeStamp) { | ||
lastTimeStamp = timeStamp; | ||
return start(); | ||
} | ||
const elapsed = timeStamp - lastTimeStamp; | ||
lastTimeStamp = timeStamp; | ||
lag += elapsed; | ||
while (lag >= timeStep) { | ||
update(engine); | ||
lag -= timeStep; | ||
} | ||
render(engine, mathAbs(lag / timeStep)); | ||
if (animationFrame) start(); | ||
} | ||
function start() { | ||
animationFrame = window.requestAnimationFrame(animate); | ||
} | ||
function stop() { | ||
window.cancelAnimationFrame(animationFrame); | ||
lastTimeStamp = null; | ||
lag = 0; | ||
animationFrame = 0; | ||
} | ||
const self = { | ||
init, | ||
destroy, | ||
start: ifAnimating(false, start), | ||
stop: ifAnimating(true, stop) | ||
}; | ||
return self; | ||
} | ||
function Engine(root, container, slides, options, eventHandler) { | ||
@@ -1109,2 +1092,3 @@ // Options | ||
dragFree, | ||
dragThreshold, | ||
slidesToScroll: groupSlides, | ||
@@ -1146,4 +1130,3 @@ skipSnaps, | ||
// Animation | ||
function update({ | ||
target, | ||
const update = ({ | ||
dragHandler, | ||
@@ -1156,11 +1139,11 @@ scrollBody, | ||
animation | ||
}) { | ||
}) => { | ||
const pointerDown = dragHandler.pointerDown(); | ||
if (!loop) scrollBounds.constrain(pointerDown); | ||
const settled = scrollBody.seek(target).settle(target); | ||
if (settled && !pointerDown) { | ||
const hasSettled = scrollBody.seek().settled(); | ||
if (hasSettled && !pointerDown) { | ||
animation.stop(); | ||
eventHandler.emit('settle'); | ||
} | ||
if (!settled) { | ||
if (!hasSettled) { | ||
eventHandler.emit('scroll'); | ||
@@ -1172,16 +1155,19 @@ } | ||
} | ||
} | ||
function draw({ | ||
}; | ||
const render = ({ | ||
scrollBody, | ||
translate, | ||
location | ||
}) { | ||
translate.to(location); | ||
} | ||
}, lagFactor) => { | ||
const velocity = scrollBody.velocity(); | ||
const lagLocation = location.get() - velocity + velocity * lagFactor; | ||
translate.to(lagLocation); | ||
}; | ||
// Shared | ||
const friction = 0.68; | ||
const animation = Animation(update, draw); | ||
const animation = Animation(update, render); | ||
const startLocation = scrollSnaps[index.get()]; | ||
const location = Vector1D(startLocation); | ||
const target = Vector1D(startLocation); | ||
const scrollBody = ScrollBody(location, duration, friction); | ||
const scrollBody = ScrollBody(location, target, duration, friction); | ||
const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target); | ||
@@ -1198,3 +1184,3 @@ const scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, eventHandler); | ||
direction, | ||
dragHandler: DragHandler(axis, direction, root, target, DragTracker(axis), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, skipSnaps, friction), | ||
dragHandler: DragHandler(axis, direction, root, target, DragTracker(axis), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction), | ||
eventStore: EventStore(), | ||
@@ -1266,2 +1252,3 @@ percentOfView, | ||
dragFree: false, | ||
dragThreshold: 10, | ||
inViewThreshold: 0, | ||
@@ -1360,3 +1347,3 @@ loop: false, | ||
if (!options.active) return deActivate(); | ||
engine.translate.to(engine.location); | ||
engine.translate.to(engine.location.get()); | ||
pluginList = withPlugins || pluginList; | ||
@@ -1363,0 +1350,0 @@ pluginApis = pluginsHandler.init(pluginList, self); |
@@ -31,6 +31,2 @@ function isNumber(subject) { | ||
} | ||
function roundToDecimals(decimalPoints) { | ||
const pow = Math.pow(10, decimalPoints); | ||
return n => Math.round(n * pow) / pow; | ||
} | ||
function arrayKeys(array) { | ||
@@ -88,74 +84,2 @@ return objectKeys(array).map(Number); | ||
function EventStore() { | ||
let listeners = []; | ||
function add(node, type, handler, options = { | ||
passive: true | ||
}) { | ||
node.addEventListener(type, handler, options); | ||
listeners.push(() => node.removeEventListener(type, handler, options)); | ||
return self; | ||
} | ||
function clear() { | ||
listeners = listeners.filter(remove => remove()); | ||
} | ||
const self = { | ||
add, | ||
clear | ||
}; | ||
return self; | ||
} | ||
function Animation(update, draw) { | ||
const documentVisibleHandler = EventStore(); | ||
const timeStep = 1000 / 60; | ||
let lastTimeStamp = null; | ||
let delta = 0; | ||
let animationFrame = 0; | ||
let engine; | ||
function init(engineInstance) { | ||
engine = engineInstance; | ||
documentVisibleHandler.add(document, 'visibilitychange', () => { | ||
if (document.hidden) lastTimeStamp = null; | ||
}); | ||
} | ||
function destroy() { | ||
stop(); | ||
documentVisibleHandler.clear(); | ||
} | ||
function ifAnimating(active, cb) { | ||
return () => { | ||
if (active === !!animationFrame) cb(); | ||
}; | ||
} | ||
function animate(timeStamp) { | ||
if (!lastTimeStamp) { | ||
lastTimeStamp = timeStamp; | ||
return start(); | ||
} | ||
delta += timeStamp - lastTimeStamp; | ||
lastTimeStamp = timeStamp; | ||
while (delta >= timeStep) { | ||
update(engine); | ||
delta -= timeStep; | ||
} | ||
draw(engine); | ||
if (animationFrame) start(); | ||
} | ||
function start() { | ||
animationFrame = window.requestAnimationFrame(animate); | ||
} | ||
function stop() { | ||
window.cancelAnimationFrame(animationFrame); | ||
lastTimeStamp = null; | ||
animationFrame = 0; | ||
} | ||
const self = { | ||
init, | ||
destroy, | ||
start: ifAnimating(false, start), | ||
stop: ifAnimating(true, stop) | ||
}; | ||
return self; | ||
} | ||
function Axis(axis, direction) { | ||
@@ -268,42 +192,17 @@ const scroll = axis === 'y' ? 'y' : 'x'; | ||
function Vector1D(value) { | ||
let vector = value; | ||
function get() { | ||
return vector; | ||
} | ||
function set(n) { | ||
vector = readNumber(n); | ||
function EventStore() { | ||
let listeners = []; | ||
function add(node, type, handler, options = { | ||
passive: true | ||
}) { | ||
node.addEventListener(type, handler, options); | ||
listeners.push(() => node.removeEventListener(type, handler, options)); | ||
return self; | ||
} | ||
function add(n) { | ||
vector += readNumber(n); | ||
return self; | ||
function clear() { | ||
listeners = listeners.filter(remove => remove()); | ||
} | ||
function subtract(n) { | ||
vector -= readNumber(n); | ||
return self; | ||
} | ||
function multiply(n) { | ||
vector *= n; | ||
return self; | ||
} | ||
function divide(n) { | ||
vector /= n; | ||
return self; | ||
} | ||
function normalize() { | ||
if (vector !== 0) divide(vector); | ||
return self; | ||
} | ||
function readNumber(n) { | ||
return isNumber(n) ? n : n.get(); | ||
} | ||
const self = { | ||
add, | ||
divide, | ||
get, | ||
multiply, | ||
normalize, | ||
set, | ||
subtract | ||
clear | ||
}; | ||
@@ -313,3 +212,3 @@ return self; | ||
function DragHandler(axis, direction, rootNode, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, skipSnaps, baseFriction) { | ||
function DragHandler(axis, direction, rootNode, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction) { | ||
const { | ||
@@ -322,3 +221,2 @@ cross: crossAxis | ||
}; | ||
const dragStartPoint = Vector1D(0); | ||
const initEvents = EventStore(); | ||
@@ -384,3 +282,2 @@ const dragEvents = EventStore(); | ||
dragTracker.pointerDown(evt); | ||
dragStartPoint.set(target); | ||
scrollBody.useFriction(0).useDuration(0); | ||
@@ -394,8 +291,8 @@ target.set(location); | ||
function move(evt) { | ||
const lastScroll = dragTracker.readPoint(evt); | ||
const lastCross = dragTracker.readPoint(evt, crossAxis); | ||
const diffScroll = deltaAbs(lastScroll, startScroll); | ||
const diffCross = deltaAbs(lastCross, startCross); | ||
if (!preventScroll && !isMouse) { | ||
if (!evt.cancelable) return up(evt); | ||
const lastScroll = dragTracker.readPoint(evt); | ||
const lastCross = dragTracker.readPoint(evt, crossAxis); | ||
const diffScroll = deltaAbs(lastScroll, startScroll); | ||
const diffCross = deltaAbs(lastCross, startCross); | ||
preventScroll = diffScroll > diffCross; | ||
@@ -405,3 +302,3 @@ if (!preventScroll) return up(evt); | ||
const diff = dragTracker.pointerMove(evt); | ||
if (diff) preventClick = true; | ||
if (diffScroll > dragThreshold) preventClick = true; | ||
scrollBody.useFriction(0.3).useDuration(1); | ||
@@ -542,30 +439,32 @@ animation.start(); | ||
function ScrollBody(location, baseDuration, baseFriction) { | ||
const roundToTwoDecimals = roundToDecimals(2); | ||
const attraction = Vector1D(0); | ||
let attractionDirection = 0; | ||
function ScrollBody(location, target, baseDuration, baseFriction) { | ||
let hasSettled = true; | ||
let bodyVelocity = 0; | ||
let scrollDirection = 0; | ||
let duration = baseDuration; | ||
let friction = baseFriction; | ||
function seek(target) { | ||
function seek() { | ||
const diff = target.get() - location.get(); | ||
const isInstant = !friction || !duration; | ||
if (isInstant) { | ||
attraction.set(0); | ||
bodyVelocity = 0; | ||
location.set(target); | ||
} else { | ||
attraction.add(diff / duration); | ||
attraction.multiply(friction); | ||
location.add(attraction); | ||
bodyVelocity += diff / duration; | ||
bodyVelocity *= friction; | ||
location.add(bodyVelocity); | ||
} | ||
attractionDirection = mathSign(attraction.get() || diff); | ||
scrollDirection = mathSign(bodyVelocity || diff); | ||
hasSettled = mathAbs(diff) < 0.001; | ||
return self; | ||
} | ||
function settle(target) { | ||
const diff = target.get() - location.get(); | ||
const hasSettled = !roundToTwoDecimals(diff); | ||
function settled() { | ||
if (hasSettled) location.set(target); | ||
return hasSettled; | ||
} | ||
function velocity() { | ||
return bodyVelocity; | ||
} | ||
function direction() { | ||
return attractionDirection; | ||
return scrollDirection; | ||
} | ||
@@ -589,7 +488,8 @@ function useBaseDuration() { | ||
seek, | ||
settle, | ||
settled, | ||
useBaseFriction, | ||
useBaseDuration, | ||
useFriction, | ||
useDuration | ||
useDuration, | ||
velocity | ||
}; | ||
@@ -841,2 +741,28 @@ return self; | ||
function Vector1D(initialValue) { | ||
let value = initialValue; | ||
function get() { | ||
return value; | ||
} | ||
function set(n) { | ||
value = normalizeInput(n); | ||
} | ||
function add(n) { | ||
value += normalizeInput(n); | ||
} | ||
function subtract(n) { | ||
value -= normalizeInput(n); | ||
} | ||
function normalizeInput(n) { | ||
return isNumber(n) ? n : n.get(); | ||
} | ||
const self = { | ||
get, | ||
set, | ||
add, | ||
subtract | ||
}; | ||
return self; | ||
} | ||
function Translate(axis, direction, container) { | ||
@@ -854,3 +780,3 @@ const translate = axis.scroll === 'x' ? x : y; | ||
if (disabled) return; | ||
containerStyle.transform = translate(direction.apply(target.get())); | ||
containerStyle.transform = translate(direction.apply(target)); | ||
} | ||
@@ -897,6 +823,5 @@ function toggleActive(active) { | ||
const point = bounds[isStartEdge ? 'end' : 'start']; | ||
const shift = Vector1D(-1); | ||
const location = Vector1D(-1); | ||
const translate = Translate(axis, direction, slides[index]); | ||
const target = () => shift.set(scroll.get() > point ? initial : altered); | ||
const target = () => scroll.get() > point ? initial : altered; | ||
return { | ||
@@ -936,4 +861,4 @@ index, | ||
const shift = target(); | ||
if (shift.get() === location.get()) return; | ||
if (shift.get() === 0) translate.clear();else translate.to(shift); | ||
if (shift === location.get()) return; | ||
translate.to(shift); | ||
location.set(shift); | ||
@@ -1095,2 +1020,60 @@ }); | ||
function Animation(update, render) { | ||
const documentVisibleHandler = EventStore(); | ||
const timeStep = 1000 / 60; | ||
let lastTimeStamp = null; | ||
let lag = 0; | ||
let animationFrame = 0; | ||
let engine; | ||
function init(engineInstance) { | ||
engine = engineInstance; | ||
documentVisibleHandler.add(document, 'visibilitychange', () => { | ||
if (document.hidden) { | ||
lastTimeStamp = null; | ||
lag = 0; | ||
} | ||
}); | ||
} | ||
function destroy() { | ||
stop(); | ||
documentVisibleHandler.clear(); | ||
} | ||
function ifAnimating(active, cb) { | ||
return () => { | ||
if (active === !!animationFrame) cb(); | ||
}; | ||
} | ||
function animate(timeStamp) { | ||
if (!lastTimeStamp) { | ||
lastTimeStamp = timeStamp; | ||
return start(); | ||
} | ||
const elapsed = timeStamp - lastTimeStamp; | ||
lastTimeStamp = timeStamp; | ||
lag += elapsed; | ||
while (lag >= timeStep) { | ||
update(engine); | ||
lag -= timeStep; | ||
} | ||
render(engine, mathAbs(lag / timeStep)); | ||
if (animationFrame) start(); | ||
} | ||
function start() { | ||
animationFrame = window.requestAnimationFrame(animate); | ||
} | ||
function stop() { | ||
window.cancelAnimationFrame(animationFrame); | ||
lastTimeStamp = null; | ||
lag = 0; | ||
animationFrame = 0; | ||
} | ||
const self = { | ||
init, | ||
destroy, | ||
start: ifAnimating(false, start), | ||
stop: ifAnimating(true, stop) | ||
}; | ||
return self; | ||
} | ||
function Engine(root, container, slides, options, eventHandler) { | ||
@@ -1107,2 +1090,3 @@ // Options | ||
dragFree, | ||
dragThreshold, | ||
slidesToScroll: groupSlides, | ||
@@ -1144,4 +1128,3 @@ skipSnaps, | ||
// Animation | ||
function update({ | ||
target, | ||
const update = ({ | ||
dragHandler, | ||
@@ -1154,11 +1137,11 @@ scrollBody, | ||
animation | ||
}) { | ||
}) => { | ||
const pointerDown = dragHandler.pointerDown(); | ||
if (!loop) scrollBounds.constrain(pointerDown); | ||
const settled = scrollBody.seek(target).settle(target); | ||
if (settled && !pointerDown) { | ||
const hasSettled = scrollBody.seek().settled(); | ||
if (hasSettled && !pointerDown) { | ||
animation.stop(); | ||
eventHandler.emit('settle'); | ||
} | ||
if (!settled) { | ||
if (!hasSettled) { | ||
eventHandler.emit('scroll'); | ||
@@ -1170,16 +1153,19 @@ } | ||
} | ||
} | ||
function draw({ | ||
}; | ||
const render = ({ | ||
scrollBody, | ||
translate, | ||
location | ||
}) { | ||
translate.to(location); | ||
} | ||
}, lagFactor) => { | ||
const velocity = scrollBody.velocity(); | ||
const lagLocation = location.get() - velocity + velocity * lagFactor; | ||
translate.to(lagLocation); | ||
}; | ||
// Shared | ||
const friction = 0.68; | ||
const animation = Animation(update, draw); | ||
const animation = Animation(update, render); | ||
const startLocation = scrollSnaps[index.get()]; | ||
const location = Vector1D(startLocation); | ||
const target = Vector1D(startLocation); | ||
const scrollBody = ScrollBody(location, duration, friction); | ||
const scrollBody = ScrollBody(location, target, duration, friction); | ||
const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target); | ||
@@ -1196,3 +1182,3 @@ const scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, eventHandler); | ||
direction, | ||
dragHandler: DragHandler(axis, direction, root, target, DragTracker(axis), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, skipSnaps, friction), | ||
dragHandler: DragHandler(axis, direction, root, target, DragTracker(axis), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction), | ||
eventStore: EventStore(), | ||
@@ -1264,2 +1250,3 @@ percentOfView, | ||
dragFree: false, | ||
dragThreshold: 10, | ||
inViewThreshold: 0, | ||
@@ -1358,3 +1345,3 @@ loop: false, | ||
if (!options.active) return deActivate(); | ||
engine.translate.to(engine.location); | ||
engine.translate.to(engine.location.get()); | ||
pluginList = withPlugins || pluginList; | ||
@@ -1361,0 +1348,0 @@ pluginApis = pluginsHandler.init(pluginList, self); |
@@ -1,1 +0,1 @@ | ||
!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"string"==typeof n}function e(n){return"boolean"==typeof n}function r(n){return"[object Object]"===Object.prototype.toString.call(n)}function o(n){return"undefined"!=typeof MouseEvent&&n instanceof MouseEvent}function i(n){return Math.abs(n)}function c(n){return Math.sign(n)}function u(n,t){return i(n-t)}function s(n){return l(n).map(Number)}function a(n){return n[d(n)]}function d(n){return Math.max(0,n.length-1)}function l(n){return Object.keys(n)}function f(n,t){return[n,t].reduce(((n,t)=>(l(t).forEach((e=>{const o=n[e],i=t[e],c=r(o)&&r(i);n[e]=c?f(o,i):i})),n)),{})}function p(t,e){const 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 m(){let n=[];const t={add:function(e,r,o,i={passive:!0}){return e.addEventListener(r,o,i),n.push((()=>e.removeEventListener(r,o,i))),t},clear:function(){n=n.filter((n=>n()))}};return t}function g(n,t){const e=i(n-t);function r(t){return t<n}function o(n){return n>t}function c(n){return r(n)||o(n)}return{length:e,max:t,min:n,constrain:function(e){return c(e)?r(e)?n:t:e},reachedAny:c,reachedMax:o,reachedMin:r,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function h(n,t,e){const{min:r,constrain:o}=g(0,n),c=n+1;let u=s(t);function s(n){return e?i((c+n)%c):o(n)}function a(){return u}function d(n){return u=s(n),l}const l={add:function(n){return d(a()+n)},clone:function(){return h(n,a(),e)},get:a,set:d,min:r,max:n};return l}function x(t){let e=t;function r(n){return e/=n,i}function o(t){return n(t)?t:t.get()}const 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 y(n,t,r,s,a,d,l,f,p,h,y,v,b,S,w,E){const{cross:M}=n,D=["INPUT","SELECT","TEXTAREA"],A={passive:!1},I=x(0),O=m(),P=m(),z=g(50,225).constrain(b.measure(20)),T={mouse:300,touch:400},L={mouse:500,touch:600},k=S?43:25;let B=!1,H=0,F=0,N=!1,C=!1,R=!1,V=!1;function j(n){if(!C&&!V){if(!n.cancelable)return U(n);const t=a.readPoint(n),e=a.readPoint(n,M),r=u(t,H),o=u(e,F);if(C=r>o,!C)return U(n)}const e=a.pointerMove(n);e&&(R=!0),p.useFriction(.3).useDuration(1),l.start(),s.add(t.apply(e)),n.preventDefault()}function U(n){const e=h.byDistance(0,!1).index!==y.get(),r=a.pointerUp(n)*(S?L:T)[V?"mouse":"touch"],o=function(n,t){const e=y.clone().add(-1*c(n)),r=h.byDistance(n,!S).distance;return S||i(n)<z?r:w&&t?.5*r:h.byIndex(e.get(),0).distance}(t.apply(r),e),s=function(n,t){if(0===n||0===t)return 0;if(i(n)<=i(t))return 0;const e=u(i(n),i(t));return i(e/n)}(r,o),d=k-10*s,l=E+s/50;C=!1,N=!1,P.clear(),p.useDuration(d).useFriction(l),f.distance(o,!S),V=!1,v.emit("pointerUp")}function q(n){R&&(n.stopPropagation(),n.preventDefault())}return{init:function(n,t){if(!t)return;function i(i){(e(t)||t(n,i))&&function(n){const t=o(n);if(V=t,t&&0!==n.button)return;if(function(n){const t=n.nodeName||"";return D.includes(t)}(n.target))return;R=S&&t&&!n.buttons&&B,B=u(s.get(),d.get())>=2,N=!0,a.pointerDown(n),I.set(s),p.useFriction(0).useDuration(0),s.set(d),function(){const n=V?document:r;P.add(n,"touchmove",j,A).add(n,"touchend",U).add(n,"mousemove",j,A).add(n,"mouseup",U)}(),H=a.readPoint(n),F=a.readPoint(n,M),v.emit("pointerDown")}(i)}const c=r;O.add(c,"dragstart",(n=>n.preventDefault()),A).add(c,"touchmove",(()=>{}),A).add(c,"touchend",(()=>{})).add(c,"touchstart",i).add(c,"mousedown",i).add(c,"touchcancel",U).add(c,"contextmenu",U).add(c,"click",q,!0)},pointerDown:function(){return N},destroy:function(){O.clear(),P.clear()}}}function v(n){let t,e;function r(n){return n.timeStamp}function c(t,e){const r="client"+("x"===(e||n.scroll)?"X":"Y");return(o(t)?t:t.touches[0])[r]}return{pointerDown:function(n){return t=n,e=n,c(n)},pointerMove:function(n){const o=c(n)-c(e),i=r(n)-r(t)>170;return e=n,i&&(t=n),o},pointerUp:function(n){if(!t||!e)return 0;const o=c(e)-c(t),u=r(n)-r(t),s=r(n)-r(e)>170,a=o/u;return u&&!s&&i(a)>.1?a:0},readPoint:c}}function b(n,t,r,o){let i,c,u=[],s=!1;function a(n){return r.measureSize(n.getBoundingClientRect())}return{init:function(r,d){if(!d)return;c=a(n),u=t.map(a),i=new ResizeObserver((i=>{s||(e(d)||d(r,i))&&function(e){for(const i of e){const e=i.target===n,s=t.indexOf(i.target);if((e?c:u[s])!==a(e?n:t[s])){r.reInit(),o.emit("resize");break}}}(i)})),[n].concat(t).forEach((n=>i.observe(n)))},destroy:function(){i&&i.disconnect(),s=!0}}}function S(n,t,e){const r=function(n){const t=Math.pow(10,n);return n=>Math.round(n*t)/t}(2),o=x(0);let i=0,u=t,s=e;function a(n){return u=n,l}function d(n){return s=n,l}const l={direction:function(){return i},seek:function(t){const e=t.get()-n.get();return!s||!u?(o.set(0),n.set(t)):(o.add(e/u),o.multiply(s),n.add(o)),i=c(o.get()||e),l},settle:function(t){const e=t.get()-n.get(),o=!r(e);return o&&n.set(t),o},useBaseFriction:function(){return d(e)},useBaseDuration:function(){return a(t)},useFriction:d,useDuration:a};return l}function w(n,t,e,r,o){const c=o.measure(10),u=o.measure(50),s=g(.1,.99);let a=!1;return{constrain:function(o){if(a||!n.reachedAny(e.get())||!n.reachedAny(t.get()))return;const d=n.reachedMin(t.get())?"min":"max",l=i(n[d]-t.get()),f=e.get()-t.get(),p=s.constrain(l/u);e.subtract(f*p),!o&&i(f)<c&&(e.set(n.constrain(e.get())),r.useDuration(25).useBaseFriction())},toggleActive:function(n){a=!n}}}function E(n,t,e,r){const o=g(-t+n,e[0]),i=e.map(o.constrain);return{snapsContained:function(){if(t<=n)return[o.max];if("keepSnaps"===r)return i;const{min:e,max:c}=function(){const n=i[0],t=a(i),e=i.lastIndexOf(n),r=i.indexOf(t)+1;return g(e,r)}();return i.slice(e,c)}()}}function M(n,t,e,r){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:u}=g(o,i);return{loop:function(t){if(!function(n){return 1===n?u(e.get()):-1===n&&c(e.get())}(t))return;const o=n*(-1*t);r.forEach((n=>n.add(o)))}}}function D(n){const{max:t,length:e}=n;return{get:function(n){return(n-t)/-e}}}function A(n,t,e,r,o){const{reachedAny:u,removeOffset:s,constrain:a}=r;function d(n){return n.concat().sort(((n,t)=>i(n)-i(t)))[0]}function l(t,r){const o=[t,t+e,t-e];if(!n)return o[0];if(!r)return d(o);return d(o.filter((n=>c(n)===r)))}return{byDistance:function(e,r){const c=o.get()+e,{index:d,distance:f}=function(e){const r=n?s(e):a(e),o=t.map((n=>n-r)).map((n=>l(n,0))).map(((n,t)=>({diff:n,index:t}))).sort(((n,t)=>i(n.diff)-i(t.diff))),{index:c}=o[0];return{index:c,distance:r}}(c),p=!n&&u(c);return!r||p?{index:d,distance:e}:{index:d,distance:e+l(t[d]-f,0)}},byIndex:function(n,e){return{index:n,distance:l(t[n]-o.get(),e)}},shortcut:l}}function I(n,t,e){const r="x"===n.scroll?function(n){return`translate3d(${n}px,0px,0px)`}:function(n){return`translate3d(0px,${n}px,0px)`},o=e.style;let 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 O(n,t,e,r,o,i,c,u,a){const d=s(o),l=s(o).reverse(),f=function(){const n=i[0]-1;return g(m(l,n),"end")}().concat(function(){const n=e-i[0]-1;return g(m(d,n),"start")}());function p(n,t){return n.reduce(((n,t)=>n-o[t]),t)}function m(n,t){return n.reduce(((n,e)=>p(n,t)>0?n.concat([e]):n),[])}function g(e,o){const i="start"===o,s=i?-r:r,d=c.findSlideBounds([s]);return e.map((e=>{const o=i?0:-r,c=i?r:0,s=d.filter((n=>n.index===e))[0][i?"end":"start"],l=x(-1),f=x(-1),p=I(n,t,a[e]);return{index:e,location:f,translate:p,target:()=>l.set(u.get()>s?o:c)}}))}return{canLoop:function(){return f.every((({index:n})=>p(d.filter((t=>t!==n)),e)<=.1))},clear:function(){f.forEach((n=>n.translate.clear()))},loop:function(){f.forEach((n=>{const{target:t,translate:e,location:r}=n,o=t();o.get()!==r.get()&&(0===o.get()?e.clear():e.to(o),r.set(o))}))},loopPoints:f}}function P(n,t){let r,o=!1;return{init:function(i,c){c&&(r=new MutationObserver((n=>{o||(e(c)||c(i,n))&&function(n){for(const e of n)if("childList"===e.type){i.reInit(),t.emit("slidesChanged");break}}(n)})),r.observe(n,{childList:!0}))},destroy:function(){r&&r.disconnect(),o=!0}}}function z(n,t,e,r,o,i,c){const{removeOffset:u,constrain:s}=o,a=i?[0,t,-t]:[0],d=l(a,c);function l(t,o){const i=t||a,c=function(n){const t=n||0;return e.map((n=>g(.5,n-.5).constrain(n*t)))}(o);return i.reduce(((t,o)=>{const i=r.map(((t,r)=>({start:t-e[r]+c[r]+o,end:t+n-c[r]+o,index:r})));return t.concat(i)}),[])}return{check:function(n,t){const e=i?u(n):s(n);return(t||d).reduce(((n,t)=>{const{index:r,start:o,end:i}=t;return!n.includes(r)&&(o<e&&i>e)?n.concat([r]):n}),[])},findSlideBounds:l}}function T(t,e,r){const o=n(r);return{groupSlides:function(n){return o?function(n,t){return s(n).filter((n=>n%t==0)).map((e=>n.slice(e,e+t)))}(n,r):function(n){return s(n).reduce(((n,r)=>{const o=e.slice(a(n),r+1).reduce(((n,t)=>n+t),0);return!r||o>t?n.concat(r):n}),[]).map(((t,e,r)=>n.slice(t,r[e+1])))}(n)}}}function L(n,t,e,r,o){const{align:c,axis:u,direction:l,startIndex:f,inViewThreshold:L,loop:k,duration:B,dragFree:H,slidesToScroll:F,skipSnaps:N,containScroll:C}=r,R=t.getBoundingClientRect(),V=e.map((n=>n.getBoundingClientRect())),j=function(n){const t="rtl"===n?-1:1;return{apply:function(n){return n*t}}}(l),U=function(n,t){const 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){const{width:t,height:r}=n;return"x"===e?t:r}}}(u,l),q=U.measureSize(R),$=function(n){return{measure:function(t){return n*(t/100)}}}(q),G=p(c,q),Q=!k&&!!C,W=k||!!C,{slideSizes:X,slideSizesWithGaps:Y}=function(n,t,e,r,o){const{measureSize:c,startEdge:u,endEdge:s}=n,l=e[0]&&o,f=function(){if(!l)return 0;const n=e[0];return i(t[u]-n[u])}(),p=function(){if(!l)return 0;const n=window.getComputedStyle(a(r));return parseFloat(n.getPropertyValue(`margin-${s}`))}(),m=e.map(c),g=e.map(((n,t,e)=>{const r=!t,o=t===d(e);return r?m[t]+f:o?m[t]+p:e[t+1][u]-n[u]})).map(i);return{slideSizes:m,slideSizesWithGaps:g}}(U,R,V,e,W),J=T(q,Y,F),{snaps:K,snapsAligned:Z}=function(n,t,e,r,o,c,u){const{startEdge:s,endEdge:l}=n,{groupSlides:f}=c,p=f(r).map((n=>a(n)[l]-n[0][s])).map(i).map(t.measure),m=r.map((n=>e[s]-n[s])).map((n=>-i(n))),g=function(){const n=a(m)-a(o);return f(m).map((n=>n[0])).map(((t,e,r)=>{const o=!e,i=e===d(r);return u&&o?0:u&&i?n:t+p[e]}))}();return{snaps:m,snapsAligned:g}}(U,G,R,V,Y,J,Q),_=-a(K)+a(Y),{snapsContained:nn}=E(q,_,Z,C),tn=Q?nn:Z,{limit:en}=function(n,t,e){return{limit:function(){const r=t[0],o=a(t);return g(e?r-n:o,r)}()}}(_,tn,k),rn=h(d(tn),f,k),on=rn.clone(),cn=s(e);const un=function(n,t){const e=m(),r=1e3/60;let o,i=null,c=0,u=0;function s(n,t){return()=>{n===!!u&&t()}}function a(e){if(!i)return i=e,d();for(c+=e-i,i=e;c>=r;)n(o),c-=r;t(o),u&&d()}function d(){u=window.requestAnimationFrame(a)}function l(){window.cancelAnimationFrame(u),i=null,u=0}return{init:function(n){o=n,e.add(document,"visibilitychange",(()=>{document.hidden&&(i=null)}))},destroy:function(){l(),e.clear()},start:s(!1,d),stop:s(!0,l)}}((function({target:n,dragHandler:t,scrollBody:e,scrollBounds:r,scrollLooper:o,slideLooper:i,eventHandler:c,animation:u}){const s=t.pointerDown();k||r.constrain(s);const a=e.seek(n).settle(n);a&&!s&&(u.stop(),c.emit("settle")),a||c.emit("scroll"),k&&(o.loop(e.direction()),i.loop())}),(function({translate:n,location:t}){n.to(t)})),sn=tn[rn.get()],an=x(sn),dn=x(sn),ln=S(an,B,.68),fn=A(k,tn,_,en,dn),pn=function(n,t,e,r,o,i){function c(r){const c=r.distance,u=r.index!==t.get();c&&(n.start(),o.add(c)),u&&(e.set(t.get()),t.set(r.index),i.emit("select"))}return{distance:function(n,t){c(r.byDistance(n,t))},index:function(n,e){const o=t.clone().set(n);c(r.byIndex(o.get(),e))}}}(un,rn,on,fn,dn,o),mn=z(q,_,X,K,en,k,L);return{eventHandler:o,containerRect:R,slideRects:V,animation:un,axis:U,direction:j,dragHandler:y(U,j,n,dn,v(U),an,un,pn,ln,fn,rn,o,$,H,N,.68),eventStore:m(),percentOfView:$,index:rn,indexPrevious:on,limit:en,location:an,options:r,resizeHandler:b(t,e,U,o),scrollBody:ln,scrollBounds:w(en,an,dn,ln,$),scrollLooper:M(_,en,an,[an,dn]),scrollProgress:D(en),scrollSnaps:tn,scrollTarget:fn,scrollTo:pn,slideLooper:O(U,j,q,_,Y,tn,mn,an,e),slidesHandler:P(t,o),slidesInView:mn,slideIndexes:cn,slidesToScroll:J,target:dn,translate:I(U,j,t)}}const k={align:"center",axis:"x",container:null,slides:null,containScroll:null,direction:"ltr",slidesToScroll:1,breakpoints:{},dragFree:!1,inViewThreshold:0,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function B(){function n(n,t){return f(n,t||{})}const t={mergeOptions:n,optionsAtMedia:function(t){const e=t.breakpoints||{},r=l(e).filter((n=>window.matchMedia(n).matches)).map((n=>e[n])).reduce(((t,e)=>n(t,e)),{});return n(t,r)},optionsMediaQueries:function(n){return n.map((n=>l(n.breakpoints||{}))).reduce(((n,t)=>n.concat(t)),[]).map(window.matchMedia)}};return t}function H(n,e,r){const o=m(),i=function(){const n=B();let t=[];return{init:function(e,r){return t=e.filter((({options:t})=>!1!==n.optionsAtMedia(t).active)),t.forEach((t=>t.init(r,n))),e.reduce(((n,t)=>Object.assign(n,{[t.name]:t})),{})},destroy:function(){t=t.filter((n=>n.destroy()))}}}(),c=function(){const n={};let t;function e(t){return n[t]||[]}const r={init:function(n){t=n},emit:function(n){return e(n).forEach((e=>e(t,n))),r},off:function(t,o){return n[t]=e(t).filter((n=>n!==o)),r},on:function(t,o){return n[t]=e(t).concat([o]),r}};return r}(),{mergeOptions:u,optionsAtMedia:s,optionsMediaQueries:a}=B(),{on:d,off:l,emit:f}=c,p=M;let g,h,x,y,v=!1,b=u(k,H.globalOptions),S=u(b),w=[];function E(e,r){if(!v){if(b=u(b,e),S=s(b),function(){const{container:e,slides:r}=S,o=t(e)?n.querySelector(e):e;x=o||n.children[0];const i=t(r)?x.querySelectorAll(r):r;y=[].slice.call(i||x.children)}(),g=L(n,x,y,S,c),!S.active)return D();if(g.translate.to(g.location),w=r||w,h=i.init(w,P),a([b,...w.map((({options:n})=>n))]).forEach((n=>o.add(n,"change",M))),g.animation.init(g),g.eventHandler.init(P),g.resizeHandler.init(P,S.watchResize),g.slidesHandler.init(P,S.watchSlides),S.loop){if(!g.slideLooper.canLoop())return D(),E({loop:!1},r),void(b=u(b,{loop:!0}));g.slideLooper.loop()}x.offsetParent&&y.length&&g.dragHandler.init(P,S.watchDrag)}}function M(n,t){const e=O();D(),E(u({startIndex:e},n),t),c.emit("reInit")}function D(){g.dragHandler.destroy(),g.animation.destroy(),g.eventStore.clear(),g.translate.clear(),g.slideLooper.clear(),g.resizeHandler.destroy(),g.slidesHandler.destroy(),i.destroy(),o.clear()}function A(n){const t=g[n?"target":"location"].get(),e=S.loop?"removeOffset":"constrain";return g.slidesInView.check(g.limit[e](t))}function I(n,t,e){S.active&&!v&&(g.scrollBody.useBaseFriction().useDuration(t?0:S.duration),g.scrollTo.index(n,e||0))}function O(){return g.index.get()}const P={canScrollNext:function(){return g.index.clone().add(1).get()!==O()},canScrollPrev:function(){return g.index.clone().add(-1).get()!==O()},containerNode:function(){return x},internalEngine:function(){return g},destroy:function(){v||(v=!0,o.clear(),D(),c.emit("destroy"))},off:l,on:d,emit:f,plugins:function(){return h},previousScrollSnap:function(){return g.indexPrevious.get()},reInit:p,rootNode:function(){return n},scrollNext:function(n){I(g.index.clone().add(1).get(),!0===n,-1)},scrollPrev:function(n){I(g.index.clone().add(-1).get(),!0===n,1)},scrollProgress:function(){return g.scrollProgress.get(g.location.get())},scrollSnapList:function(){return g.scrollSnaps.map(g.scrollProgress.get)},scrollTo:I,selectedScrollSnap:O,slideNodes:function(){return y},slidesInView:A,slidesNotInView:function(n){const t=A(n);return g.slideIndexes.filter((n=>!t.includes(n)))}};return E(e,r),setTimeout((()=>c.emit("init")),0),P}return H.globalOptions=void 0,H})); | ||
!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"string"==typeof n}function e(n){return"boolean"==typeof n}function r(n){return"[object Object]"===Object.prototype.toString.call(n)}function o(n){return"undefined"!=typeof MouseEvent&&n instanceof MouseEvent}function i(n){return Math.abs(n)}function c(n){return Math.sign(n)}function u(n,t){return i(n-t)}function s(n){return l(n).map(Number)}function a(n){return n[d(n)]}function d(n){return Math.max(0,n.length-1)}function l(n){return Object.keys(n)}function f(n,t){return[n,t].reduce(((n,t)=>(l(t).forEach((e=>{const o=n[e],i=t[e],c=r(o)&&r(i);n[e]=c?f(o,i):i})),n)),{})}function p(t,e){const 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 m(n,t){const e=i(n-t);function r(t){return t<n}function o(n){return n>t}function c(n){return r(n)||o(n)}return{length:e,max:t,min:n,constrain:function(e){return c(e)?r(e)?n:t:e},reachedAny:c,reachedMax:o,reachedMin:r,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function g(n,t,e){const{min:r,constrain:o}=m(0,n),c=n+1;let u=s(t);function s(n){return e?i((c+n)%c):o(n)}function a(){return u}function d(n){return u=s(n),l}const l={add:function(n){return d(a()+n)},clone:function(){return g(n,a(),e)},get:a,set:d,min:r,max:n};return l}function h(){let n=[];const t={add:function(e,r,o,i={passive:!0}){return e.addEventListener(r,o,i),n.push((()=>e.removeEventListener(r,o,i))),t},clear:function(){n=n.filter((n=>n()))}};return t}function x(n,t,r,s,a,d,l,f,p,g,x,y,v,b,S,w,E){const{cross:D}=n,M=["INPUT","SELECT","TEXTAREA"],A={passive:!1},I=h(),O=h(),P=m(50,225).constrain(v.measure(20)),T={mouse:300,touch:400},z={mouse:500,touch:600},B=b?43:25;let L=!1,k=0,H=0,F=!1,N=!1,C=!1,R=!1;function V(n){const e=a.readPoint(n),r=a.readPoint(n,D),o=u(e,k),i=u(r,H);if(!N&&!R){if(!n.cancelable)return j(n);if(N=o>i,!N)return j(n)}const c=a.pointerMove(n);o>S&&(C=!0),p.useFriction(.3).useDuration(1),l.start(),s.add(t.apply(c)),n.preventDefault()}function j(n){const e=g.byDistance(0,!1).index!==x.get(),r=a.pointerUp(n)*(b?z:T)[R?"mouse":"touch"],o=function(n,t){const e=x.clone().add(-1*c(n)),r=g.byDistance(n,!b).distance;return b||i(n)<P?r:w&&t?.5*r:g.byIndex(e.get(),0).distance}(t.apply(r),e),s=function(n,t){if(0===n||0===t)return 0;if(i(n)<=i(t))return 0;const e=u(i(n),i(t));return i(e/n)}(r,o),d=B-10*s,l=E+s/50;N=!1,F=!1,O.clear(),p.useDuration(d).useFriction(l),f.distance(o,!b),R=!1,y.emit("pointerUp")}function U(n){C&&(n.stopPropagation(),n.preventDefault())}return{init:function(n,t){if(!t)return;function i(i){(e(t)||t(n,i))&&function(n){const t=o(n);if(R=t,t&&0!==n.button)return;if(function(n){const t=n.nodeName||"";return M.includes(t)}(n.target))return;C=b&&t&&!n.buttons&&L,L=u(s.get(),d.get())>=2,F=!0,a.pointerDown(n),p.useFriction(0).useDuration(0),s.set(d),function(){const n=R?document:r;O.add(n,"touchmove",V,A).add(n,"touchend",j).add(n,"mousemove",V,A).add(n,"mouseup",j)}(),k=a.readPoint(n),H=a.readPoint(n,D),y.emit("pointerDown")}(i)}const c=r;I.add(c,"dragstart",(n=>n.preventDefault()),A).add(c,"touchmove",(()=>{}),A).add(c,"touchend",(()=>{})).add(c,"touchstart",i).add(c,"mousedown",i).add(c,"touchcancel",j).add(c,"contextmenu",j).add(c,"click",U,!0)},pointerDown:function(){return F},destroy:function(){I.clear(),O.clear()}}}function y(n){let t,e;function r(n){return n.timeStamp}function c(t,e){const r="client"+("x"===(e||n.scroll)?"X":"Y");return(o(t)?t:t.touches[0])[r]}return{pointerDown:function(n){return t=n,e=n,c(n)},pointerMove:function(n){const o=c(n)-c(e),i=r(n)-r(t)>170;return e=n,i&&(t=n),o},pointerUp:function(n){if(!t||!e)return 0;const o=c(e)-c(t),u=r(n)-r(t),s=r(n)-r(e)>170,a=o/u;return u&&!s&&i(a)>.1?a:0},readPoint:c}}function v(n,t,r,o){let i,c,u=[],s=!1;function a(n){return r.measureSize(n.getBoundingClientRect())}return{init:function(r,d){if(!d)return;c=a(n),u=t.map(a),i=new ResizeObserver((i=>{s||(e(d)||d(r,i))&&function(e){for(const i of e){const e=i.target===n,s=t.indexOf(i.target);if((e?c:u[s])!==a(e?n:t[s])){r.reInit(),o.emit("resize");break}}}(i)})),[n].concat(t).forEach((n=>i.observe(n)))},destroy:function(){i&&i.disconnect(),s=!0}}}function b(n,t,e,r,o){const c=o.measure(10),u=o.measure(50),s=m(.1,.99);let a=!1;return{constrain:function(o){if(a||!n.reachedAny(e.get())||!n.reachedAny(t.get()))return;const d=n.reachedMin(t.get())?"min":"max",l=i(n[d]-t.get()),f=e.get()-t.get(),p=s.constrain(l/u);e.subtract(f*p),!o&&i(f)<c&&(e.set(n.constrain(e.get())),r.useDuration(25).useBaseFriction())},toggleActive:function(n){a=!n}}}function S(n,t,e,r){const o=m(-t+n,e[0]),i=e.map(o.constrain);return{snapsContained:function(){if(t<=n)return[o.max];if("keepSnaps"===r)return i;const{min:e,max:c}=function(){const n=i[0],t=a(i),e=i.lastIndexOf(n),r=i.indexOf(t)+1;return m(e,r)}();return i.slice(e,c)}()}}function w(n,t,e,r){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:u}=m(o,i);return{loop:function(t){if(!function(n){return 1===n?u(e.get()):-1===n&&c(e.get())}(t))return;const o=n*(-1*t);r.forEach((n=>n.add(o)))}}}function E(n){const{max:t,length:e}=n;return{get:function(n){return(n-t)/-e}}}function D(n,t,e,r,o){const{reachedAny:u,removeOffset:s,constrain:a}=r;function d(n){return n.concat().sort(((n,t)=>i(n)-i(t)))[0]}function l(t,r){const o=[t,t+e,t-e];if(!n)return o[0];if(!r)return d(o);return d(o.filter((n=>c(n)===r)))}return{byDistance:function(e,r){const c=o.get()+e,{index:d,distance:f}=function(e){const r=n?s(e):a(e),o=t.map((n=>n-r)).map((n=>l(n,0))).map(((n,t)=>({diff:n,index:t}))).sort(((n,t)=>i(n.diff)-i(t.diff))),{index:c}=o[0];return{index:c,distance:r}}(c),p=!n&&u(c);return!r||p?{index:d,distance:e}:{index:d,distance:e+l(t[d]-f,0)}},byIndex:function(n,e){return{index:n,distance:l(t[n]-o.get(),e)}},shortcut:l}}function M(t){let e=t;function r(t){return n(t)?t:t.get()}return{get:function(){return e},set:function(n){e=r(n)},add:function(n){e+=r(n)},subtract:function(n){e-=r(n)}}}function A(n,t,e){const r="x"===n.scroll?function(n){return`translate3d(${n}px,0px,0px)`}:function(n){return`translate3d(0px,${n}px,0px)`},o=e.style;let i=!1;return{clear:function(){i||(o.transform="",e.getAttribute("style")||e.removeAttribute("style"))},to:function(n){i||(o.transform=r(t.apply(n)))},toggleActive:function(n){i=!n}}}function I(n,t,e,r,o,i,c,u,a){const d=s(o),l=s(o).reverse(),f=function(){const n=i[0]-1;return g(m(l,n),"end")}().concat(function(){const n=e-i[0]-1;return g(m(d,n),"start")}());function p(n,t){return n.reduce(((n,t)=>n-o[t]),t)}function m(n,t){return n.reduce(((n,e)=>p(n,t)>0?n.concat([e]):n),[])}function g(e,o){const i="start"===o,s=i?-r:r,d=c.findSlideBounds([s]);return e.map((e=>{const o=i?0:-r,c=i?r:0,s=d.filter((n=>n.index===e))[0][i?"end":"start"],l=M(-1),f=A(n,t,a[e]);return{index:e,location:l,translate:f,target:()=>u.get()>s?o:c}}))}return{canLoop:function(){return f.every((({index:n})=>p(d.filter((t=>t!==n)),e)<=.1))},clear:function(){f.forEach((n=>n.translate.clear()))},loop:function(){f.forEach((n=>{const{target:t,translate:e,location:r}=n,o=t();o!==r.get()&&(e.to(o),r.set(o))}))},loopPoints:f}}function O(n,t){let r,o=!1;return{init:function(i,c){c&&(r=new MutationObserver((n=>{o||(e(c)||c(i,n))&&function(n){for(const e of n)if("childList"===e.type){i.reInit(),t.emit("slidesChanged");break}}(n)})),r.observe(n,{childList:!0}))},destroy:function(){r&&r.disconnect(),o=!0}}}function P(n,t,e,r,o,i,c){const{removeOffset:u,constrain:s}=o,a=i?[0,t,-t]:[0],d=l(a,c);function l(t,o){const i=t||a,c=function(n){const t=n||0;return e.map((n=>m(.5,n-.5).constrain(n*t)))}(o);return i.reduce(((t,o)=>{const i=r.map(((t,r)=>({start:t-e[r]+c[r]+o,end:t+n-c[r]+o,index:r})));return t.concat(i)}),[])}return{check:function(n,t){const e=i?u(n):s(n);return(t||d).reduce(((n,t)=>{const{index:r,start:o,end:i}=t;return!n.includes(r)&&(o<e&&i>e)?n.concat([r]):n}),[])},findSlideBounds:l}}function T(t,e,r){const o=n(r);return{groupSlides:function(n){return o?function(n,t){return s(n).filter((n=>n%t==0)).map((e=>n.slice(e,e+t)))}(n,r):function(n){return s(n).reduce(((n,r)=>{const o=e.slice(a(n),r+1).reduce(((n,t)=>n+t),0);return!r||o>t?n.concat(r):n}),[]).map(((t,e,r)=>n.slice(t,r[e+1])))}(n)}}}function z(n,t,e,r,o){const{align:u,axis:l,direction:f,startIndex:z,inViewThreshold:B,loop:L,duration:k,dragFree:H,dragThreshold:F,slidesToScroll:N,skipSnaps:C,containScroll:R}=r,V=t.getBoundingClientRect(),j=e.map((n=>n.getBoundingClientRect())),U=function(n){const t="rtl"===n?-1:1;return{apply:function(n){return n*t}}}(f),q=function(n,t){const 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){const{width:t,height:r}=n;return"x"===e?t:r}}}(l,f),$=q.measureSize(V),G=function(n){return{measure:function(t){return n*(t/100)}}}($),Q=p(u,$),W=!L&&!!R,X=L||!!R,{slideSizes:Y,slideSizesWithGaps:J}=function(n,t,e,r,o){const{measureSize:c,startEdge:u,endEdge:s}=n,l=e[0]&&o,f=function(){if(!l)return 0;const n=e[0];return i(t[u]-n[u])}(),p=function(){if(!l)return 0;const n=window.getComputedStyle(a(r));return parseFloat(n.getPropertyValue(`margin-${s}`))}(),m=e.map(c),g=e.map(((n,t,e)=>{const r=!t,o=t===d(e);return r?m[t]+f:o?m[t]+p:e[t+1][u]-n[u]})).map(i);return{slideSizes:m,slideSizesWithGaps:g}}(q,V,j,e,X),K=T($,J,N),{snaps:Z,snapsAligned:_}=function(n,t,e,r,o,c,u){const{startEdge:s,endEdge:l}=n,{groupSlides:f}=c,p=f(r).map((n=>a(n)[l]-n[0][s])).map(i).map(t.measure),m=r.map((n=>e[s]-n[s])).map((n=>-i(n))),g=function(){const n=a(m)-a(o);return f(m).map((n=>n[0])).map(((t,e,r)=>{const o=!e,i=e===d(r);return u&&o?0:u&&i?n:t+p[e]}))}();return{snaps:m,snapsAligned:g}}(q,Q,V,j,J,K,W),nn=-a(Z)+a(J),{snapsContained:tn}=S($,nn,_,R),en=W?tn:_,{limit:rn}=function(n,t,e){return{limit:function(){const r=t[0],o=a(t);return m(e?r-n:o,r)}()}}(nn,en,L),on=g(d(en),z,L),cn=on.clone(),un=s(e),sn=function(n,t){const e=h(),r=1e3/60;let o,c=null,u=0,s=0;function a(n,t){return()=>{n===!!s&&t()}}function d(e){if(!c)return c=e,l();const a=e-c;for(c=e,u+=a;u>=r;)n(o),u-=r;t(o,i(u/r)),s&&l()}function l(){s=window.requestAnimationFrame(d)}function f(){window.cancelAnimationFrame(s),c=null,u=0,s=0}return{init:function(n){o=n,e.add(document,"visibilitychange",(()=>{document.hidden&&(c=null,u=0)}))},destroy:function(){f(),e.clear()},start:a(!1,l),stop:a(!0,f)}}((({dragHandler:n,scrollBody:t,scrollBounds:e,scrollLooper:r,slideLooper:o,eventHandler:i,animation:c})=>{const u=n.pointerDown();L||e.constrain(u);const s=t.seek().settled();s&&!u&&(c.stop(),i.emit("settle")),s||i.emit("scroll"),L&&(r.loop(t.direction()),o.loop())}),(({scrollBody:n,translate:t,location:e},r)=>{const o=n.velocity(),i=e.get()-o+o*r;t.to(i)})),an=en[on.get()],dn=M(an),ln=M(an),fn=function(n,t,e,r){let o=!0,u=0,s=0,a=e,d=r;function l(n){return a=n,p}function f(n){return d=n,p}const p={direction:function(){return s},seek:function(){const e=t.get()-n.get();return d&&a?(u+=e/a,u*=d,n.add(u)):(u=0,n.set(t)),s=c(u||e),o=i(e)<.001,p},settled:function(){return o&&n.set(t),o},useBaseFriction:function(){return f(r)},useBaseDuration:function(){return l(e)},useFriction:f,useDuration:l,velocity:function(){return u}};return p}(dn,ln,k,.68),pn=D(L,en,nn,rn,ln),mn=function(n,t,e,r,o,i){function c(r){const c=r.distance,u=r.index!==t.get();c&&(n.start(),o.add(c)),u&&(e.set(t.get()),t.set(r.index),i.emit("select"))}return{distance:function(n,t){c(r.byDistance(n,t))},index:function(n,e){const o=t.clone().set(n);c(r.byIndex(o.get(),e))}}}(sn,on,cn,pn,ln,o),gn=P($,nn,Y,Z,rn,L,B);return{eventHandler:o,containerRect:V,slideRects:j,animation:sn,axis:q,direction:U,dragHandler:x(q,U,n,ln,y(q),dn,sn,mn,fn,pn,on,o,G,H,F,C,.68),eventStore:h(),percentOfView:G,index:on,indexPrevious:cn,limit:rn,location:dn,options:r,resizeHandler:v(t,e,q,o),scrollBody:fn,scrollBounds:b(rn,dn,ln,fn,G),scrollLooper:w(nn,rn,dn,[dn,ln]),scrollProgress:E(rn),scrollSnaps:en,scrollTarget:pn,scrollTo:mn,slideLooper:I(q,U,$,nn,J,en,gn,dn,e),slidesHandler:O(t,o),slidesInView:gn,slideIndexes:un,slidesToScroll:K,target:ln,translate:A(q,U,t)}}const B={align:"center",axis:"x",container:null,slides:null,containScroll:null,direction:"ltr",slidesToScroll:1,breakpoints:{},dragFree:!1,dragThreshold:10,inViewThreshold:0,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function L(){function n(n,t){return f(n,t||{})}const t={mergeOptions:n,optionsAtMedia:function(t){const e=t.breakpoints||{},r=l(e).filter((n=>window.matchMedia(n).matches)).map((n=>e[n])).reduce(((t,e)=>n(t,e)),{});return n(t,r)},optionsMediaQueries:function(n){return n.map((n=>l(n.breakpoints||{}))).reduce(((n,t)=>n.concat(t)),[]).map(window.matchMedia)}};return t}function k(n,e,r){const o=h(),i=function(){const n=L();let t=[];return{init:function(e,r){return t=e.filter((({options:t})=>!1!==n.optionsAtMedia(t).active)),t.forEach((t=>t.init(r,n))),e.reduce(((n,t)=>Object.assign(n,{[t.name]:t})),{})},destroy:function(){t=t.filter((n=>n.destroy()))}}}(),c=function(){const n={};let t;function e(t){return n[t]||[]}const r={init:function(n){t=n},emit:function(n){return e(n).forEach((e=>e(t,n))),r},off:function(t,o){return n[t]=e(t).filter((n=>n!==o)),r},on:function(t,o){return n[t]=e(t).concat([o]),r}};return r}(),{mergeOptions:u,optionsAtMedia:s,optionsMediaQueries:a}=L(),{on:d,off:l,emit:f}=c,p=D;let m,g,x,y,v=!1,b=u(B,k.globalOptions),S=u(b),w=[];function E(e,r){if(!v){if(b=u(b,e),S=s(b),function(){const{container:e,slides:r}=S,o=t(e)?n.querySelector(e):e;x=o||n.children[0];const i=t(r)?x.querySelectorAll(r):r;y=[].slice.call(i||x.children)}(),m=z(n,x,y,S,c),!S.active)return M();if(m.translate.to(m.location.get()),w=r||w,g=i.init(w,P),a([b,...w.map((({options:n})=>n))]).forEach((n=>o.add(n,"change",D))),m.animation.init(m),m.eventHandler.init(P),m.resizeHandler.init(P,S.watchResize),m.slidesHandler.init(P,S.watchSlides),S.loop){if(!m.slideLooper.canLoop())return M(),E({loop:!1},r),void(b=u(b,{loop:!0}));m.slideLooper.loop()}x.offsetParent&&y.length&&m.dragHandler.init(P,S.watchDrag)}}function D(n,t){const e=O();M(),E(u({startIndex:e},n),t),c.emit("reInit")}function M(){m.dragHandler.destroy(),m.animation.destroy(),m.eventStore.clear(),m.translate.clear(),m.slideLooper.clear(),m.resizeHandler.destroy(),m.slidesHandler.destroy(),i.destroy(),o.clear()}function A(n){const t=m[n?"target":"location"].get(),e=S.loop?"removeOffset":"constrain";return m.slidesInView.check(m.limit[e](t))}function I(n,t,e){S.active&&!v&&(m.scrollBody.useBaseFriction().useDuration(t?0:S.duration),m.scrollTo.index(n,e||0))}function O(){return m.index.get()}const P={canScrollNext:function(){return m.index.clone().add(1).get()!==O()},canScrollPrev:function(){return m.index.clone().add(-1).get()!==O()},containerNode:function(){return x},internalEngine:function(){return m},destroy:function(){v||(v=!0,o.clear(),M(),c.emit("destroy"))},off:l,on:d,emit:f,plugins:function(){return g},previousScrollSnap:function(){return m.indexPrevious.get()},reInit:p,rootNode:function(){return n},scrollNext:function(n){I(m.index.clone().add(1).get(),!0===n,-1)},scrollPrev:function(n){I(m.index.clone().add(-1).get(),!0===n,1)},scrollProgress:function(){return m.scrollProgress.get(m.location.get())},scrollSnapList:function(){return m.scrollSnaps.map(m.scrollProgress.get)},scrollTo:I,selectedScrollSnap:O,slideNodes:function(){return y},slidesInView:A,slidesNotInView:function(n){const t=A(n);return m.slideIndexes.filter((n=>!t.includes(n)))}};return E(e,r),setTimeout((()=>c.emit("init")),0),P}return k.globalOptions=void 0,k})); |
{ | ||
"name": "embla-carousel", | ||
"version": "8.0.0-rc02", | ||
"version": "8.0.0-rc03", | ||
"author": "David Jerleke", | ||
@@ -5,0 +5,0 @@ "description": "A lightweight carousel library with fluid motion and great swipe precision", |
Sorry, the diff of this file is not supported yet
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
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
131126
3358