Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

embla-carousel-react

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embla-carousel-react - npm Package Compare versions

Comparing version 6.2.0 to 7.0.0-rc01

embla-carousel-react.cjs.js

8

components/utils.d.ts

@@ -1,9 +0,1 @@

import { EmblaPluginType } from 'embla-carousel';
export declare function canUseDOM(): boolean;
export declare function areObjectsEqualShallow(objectA: {
[key: string]: any;
}, objectB: {
[key: string]: any;
}): boolean;
export declare function sortAndMapPluginToOptions(plugins: EmblaPluginType[]): EmblaPluginType['options'][];
export declare function arePluginsEqual(pluginsA: EmblaPluginType[], pluginsB: EmblaPluginType[]): boolean;

1519

embla-carousel-react.esm.js

@@ -1,2 +0,3 @@

import { useState, useRef, useMemo, useEffect } from 'react';
import { useRef, useState, useEffect } from 'react';
import EmblaCarousel from 'embla-carousel';

@@ -6,1486 +7,3 @@ function canUseDOM() {

}
function areObjectsEqualShallow(objectA, objectB) {
return Object.keys(objectA).length === Object.keys(objectB).length && Object.keys(objectA).every(function (objectKey) {
if (!Object.prototype.hasOwnProperty.call(objectB, objectKey)) {
return false;
}
return objectA[objectKey] === objectB[objectKey];
});
}
function sortAndMapPluginToOptions(plugins) {
return plugins.concat().sort(function (a, b) {
return a.name > b.name ? 1 : -1;
}).map(function (plugin) {
return plugin.options;
});
}
function arePluginsEqual(pluginsA, pluginsB) {
if (pluginsA.length !== pluginsB.length) return false;
var optionsA = sortAndMapPluginToOptions(pluginsA);
var optionsB = sortAndMapPluginToOptions(pluginsB);
return optionsA.every(function (optionA, index) {
var optionB = optionsB[index];
return areObjectsEqualShallow(optionA, optionB);
});
}
function Alignment(align, viewSize) {
var predefined = {
start: start,
center: center,
end: end
};
function start() {
return 0;
}
function center(n) {
return end(n) / 2;
}
function end(n) {
return viewSize - n;
}
function percent() {
return viewSize * Number(align);
}
function measure(n) {
if (typeof align === 'number') return percent();
return predefined[align](n);
}
var self = {
measure: measure
};
return self;
}
function Animation(callback) {
var animationFrame = 0;
function ifAnimating(active, cb) {
return function () {
if (active === !!animationFrame) cb();
};
}
function start() {
animationFrame = window.requestAnimationFrame(callback);
}
function stop() {
window.cancelAnimationFrame(animationFrame);
animationFrame = 0;
}
var self = {
proceed: ifAnimating(true, start),
start: ifAnimating(false, start),
stop: ifAnimating(true, stop)
};
return self;
}
function Axis(axis, direction) {
var scroll = axis === 'y' ? 'y' : 'x';
var cross = axis === 'y' ? 'x' : 'y';
var startEdge = getStartEdge();
var endEdge = getEndEdge();
function measureSize(rect) {
var width = rect.width,
height = rect.height;
return scroll === 'x' ? width : height;
}
function getStartEdge() {
if (scroll === 'y') return 'top';
return direction === 'rtl' ? 'right' : 'left';
}
function getEndEdge() {
if (scroll === 'y') return 'bottom';
return direction === 'rtl' ? 'left' : 'right';
}
var self = {
scroll: scroll,
cross: cross,
startEdge: startEdge,
endEdge: endEdge,
measureSize: measureSize
};
return self;
}
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) {
var length = mathAbs(min - max);
function reachedMin(n) {
return n < min;
}
function reachedMax(n) {
return n > max;
}
function reachedAny(n) {
return reachedMin(n) || reachedMax(n);
}
function constrain(n) {
if (!reachedAny(n)) return n;
return reachedMin(n) ? min : max;
}
function removeOffset(n) {
if (!length) return n;
return n - length * Math.ceil((n - max) / length);
}
var self = {
length: length,
max: max,
min: min,
constrain: constrain,
reachedAny: reachedAny,
reachedMax: reachedMax,
reachedMin: reachedMin,
removeOffset: removeOffset
};
return self;
}
function Counter(max, start, loop) {
var _a = Limit(0, max),
min = _a.min,
constrain = _a.constrain;
var loopEnd = max + 1;
var counter = withinLimit(start);
function withinLimit(n) {
return !loop ? constrain(n) : mathAbs((loopEnd + n) % loopEnd);
}
function get() {
return counter;
}
function set(n) {
counter = withinLimit(n);
return self;
}
function add(n) {
return set(get() + n);
}
function clone() {
return Counter(max, get(), loop);
}
var self = {
add: add,
clone: clone,
get: get,
set: set,
min: min,
max: max
};
return self;
}
function Direction(direction) {
var sign = direction === 'rtl' ? -1 : 1;
function apply(n) {
return n * sign;
}
var self = {
apply: apply
};
return self;
}
function EventStore() {
var listeners = [];
function add(node, type, handler, options) {
if (options === void 0) {
options = false;
}
node.addEventListener(type, handler, options);
listeners.push(function () {
return node.removeEventListener(type, handler, options);
});
return self;
}
function removeAll() {
listeners = listeners.filter(function (remove) {
return remove();
});
return self;
}
var self = {
add: add,
removeAll: removeAll
};
return self;
}
function Vector1D(value) {
var vector = value;
function get() {
return vector;
}
function set(n) {
vector = readNumber(n);
return self;
}
function add(n) {
vector += readNumber(n);
return self;
}
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 typeof n === 'number' ? n : n.get();
}
var self = {
add: add,
divide: divide,
get: get,
multiply: multiply,
normalize: normalize,
set: set,
subtract: subtract
};
return self;
}
function DragHandler(axis, direction, rootNode, target, dragFree, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, events, loop, skipSnaps) {
var crossAxis = axis.cross;
var focusNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
var dragStartPoint = Vector1D(0);
var activationEvents = EventStore();
var interactionEvents = EventStore();
var snapForceBoost = {
mouse: 300,
touch: 400
};
var freeForceBoost = {
mouse: 500,
touch: 600
};
var baseSpeed = dragFree ? 5 : 16;
var baseMass = 1;
var dragThreshold = 20;
var startScroll = 0;
var startCross = 0;
var pointerIsDown = false;
var preventScroll = false;
var preventClick = false;
var isMouse = false;
function addActivationEvents() {
var node = rootNode;
activationEvents.add(node, 'touchmove', function () {
return undefined;
}).add(node, 'touchend', function () {
return undefined;
}).add(node, 'touchstart', down).add(node, 'mousedown', down).add(node, 'touchcancel', up).add(node, 'contextmenu', up).add(node, 'click', click);
}
function addInteractionEvents() {
var node = !isMouse ? rootNode : document;
interactionEvents.add(node, 'touchmove', move).add(node, 'touchend', up).add(node, 'mousemove', move).add(node, 'mouseup', up);
}
function removeAllEvents() {
activationEvents.removeAll();
interactionEvents.removeAll();
}
function isFocusNode(node) {
var name = node.nodeName || '';
return focusNodes.indexOf(name) > -1;
}
function forceBoost() {
var boost = dragFree ? freeForceBoost : snapForceBoost;
var type = isMouse ? 'mouse' : 'touch';
return boost[type];
}
function allowedForce(force, targetChanged) {
var next = index.clone().add(mathSign(force) * -1);
var isEdge = next.get() === index.min || next.get() === index.max;
var baseForce = scrollTarget.byDistance(force, !dragFree).distance;
if (dragFree || mathAbs(force) < dragThreshold) return baseForce;
if (!loop && isEdge) return baseForce * 0.4;
if (skipSnaps && targetChanged) return baseForce * 0.5;
return scrollTarget.byIndex(next.get(), 0).distance;
}
function down(evt) {
isMouse = evt.type === 'mousedown';
if (isMouse && evt.button !== 0) return;
var isMoving = deltaAbs(target.get(), location.get()) >= 2;
var clearPreventClick = isMouse || !isMoving;
var isNotFocusNode = !isFocusNode(evt.target);
var preventDefault = isMoving || isMouse && isNotFocusNode;
pointerIsDown = true;
dragTracker.pointerDown(evt);
dragStartPoint.set(target);
target.set(location);
scrollBody.useBaseMass().useSpeed(80);
addInteractionEvents();
startScroll = dragTracker.readPoint(evt);
startCross = dragTracker.readPoint(evt, crossAxis);
events.emit('pointerDown');
if (clearPreventClick) preventClick = false;
if (preventDefault) evt.preventDefault();
}
function move(evt) {
if (!preventScroll && !isMouse) {
if (!evt.cancelable) return up(evt);
var lastScroll = dragTracker.readPoint(evt);
var lastCross = dragTracker.readPoint(evt, crossAxis);
var diffScroll = deltaAbs(lastScroll, startScroll);
var diffCross = deltaAbs(lastCross, startCross);
preventScroll = diffScroll > diffCross;
if (!preventScroll && !preventClick) return up(evt);
}
var diff = dragTracker.pointerMove(evt);
if (!preventClick && diff) preventClick = true;
animation.start();
target.add(direction.apply(diff));
evt.preventDefault();
}
function up(evt) {
var currentLocation = scrollTarget.byDistance(0, false);
var targetChanged = currentLocation.index !== index.get();
var rawForce = dragTracker.pointerUp(evt) * forceBoost();
var force = allowedForce(direction.apply(rawForce), targetChanged);
var forceFactor = factorAbs(rawForce, force);
var isMoving = deltaAbs(target.get(), dragStartPoint.get()) >= 0.5;
var isVigorous = targetChanged && forceFactor > 0.75;
var isBelowThreshold = mathAbs(rawForce) < dragThreshold;
var speed = isVigorous ? 10 : baseSpeed;
var mass = isVigorous ? baseMass + 2.5 * forceFactor : baseMass;
if (isMoving && !isMouse) preventClick = true;
preventScroll = false;
pointerIsDown = false;
interactionEvents.removeAll();
scrollBody.useSpeed(isBelowThreshold ? 9 : speed).useMass(mass);
scrollTo.distance(force, !dragFree);
isMouse = false;
events.emit('pointerUp');
}
function click(evt) {
if (preventClick) evt.preventDefault();
}
function clickAllowed() {
return !preventClick;
}
function pointerDown() {
return pointerIsDown;
}
var self = {
addActivationEvents: addActivationEvents,
clickAllowed: clickAllowed,
pointerDown: pointerDown,
removeAllEvents: removeAllEvents
};
return self;
}
function DragTracker(axis, pxToPercent) {
var logInterval = 170;
var startEvent;
var lastEvent;
function isTouchEvent(evt) {
return typeof TouchEvent !== 'undefined' && evt instanceof TouchEvent;
}
function readTime(evt) {
return evt.timeStamp;
}
function readPoint(evt, evtAxis) {
var property = evtAxis || axis.scroll;
var coord = "client" + (property === 'x' ? 'X' : 'Y');
return (isTouchEvent(evt) ? evt.touches[0] : evt)[coord];
}
function pointerDown(evt) {
startEvent = evt;
lastEvent = evt;
return pxToPercent.measure(readPoint(evt));
}
function pointerMove(evt) {
var diff = readPoint(evt) - readPoint(lastEvent);
var expired = readTime(evt) - readTime(startEvent) > logInterval;
lastEvent = evt;
if (expired) startEvent = evt;
return pxToPercent.measure(diff);
}
function pointerUp(evt) {
if (!startEvent || !lastEvent) return 0;
var diffDrag = readPoint(lastEvent) - readPoint(startEvent);
var diffTime = readTime(evt) - readTime(startEvent);
var expired = readTime(evt) - readTime(lastEvent) > logInterval;
var force = diffDrag / diffTime;
var isFlick = diffTime && !expired && mathAbs(force) > 0.1;
return isFlick ? pxToPercent.measure(force) : 0;
}
var self = {
isTouchEvent: isTouchEvent,
pointerDown: pointerDown,
pointerMove: pointerMove,
pointerUp: pointerUp,
readPoint: readPoint
};
return self;
}
function PxToPercent(viewInPx) {
var totalPercent = 100;
function measure(n) {
if (viewInPx === 0) return 0;
return n / viewInPx * totalPercent;
}
var self = {
measure: measure,
totalPercent: totalPercent
};
return self;
}
function ScrollBody(location, baseSpeed, baseMass) {
var roundToTwoDecimals = roundToDecimals(2);
var velocity = Vector1D(0);
var acceleration = Vector1D(0);
var attraction = Vector1D(0);
var attractionDirection = 0;
var speed = baseSpeed;
var mass = baseMass;
function update() {
velocity.add(acceleration);
location.add(velocity);
acceleration.multiply(0);
}
function applyForce(force) {
force.divide(mass);
acceleration.add(force);
}
function seek(target) {
attraction.set(target).subtract(location);
var magnitude = map(attraction.get(), 0, 100, 0, speed);
attractionDirection = mathSign(attraction.get());
attraction.normalize().multiply(magnitude).subtract(velocity);
applyForce(attraction);
return self;
}
function settle(target) {
var diff = target.get() - location.get();
var hasSettled = !roundToTwoDecimals(diff);
if (hasSettled) location.set(target);
return hasSettled;
}
function direction() {
return attractionDirection;
}
function useBaseSpeed() {
return useSpeed(baseSpeed);
}
function useBaseMass() {
return useMass(baseMass);
}
function useSpeed(n) {
speed = n;
return self;
}
function useMass(n) {
mass = n;
return self;
}
var self = {
direction: direction,
seek: seek,
settle: settle,
update: update,
useBaseMass: useBaseMass,
useBaseSpeed: useBaseSpeed,
useMass: useMass,
useSpeed: useSpeed
};
return self;
}
function ScrollBounds(limit, location, target, scrollBody) {
var pullBackThreshold = 10;
var edgeOffsetTolerance = 50;
var maxFriction = 0.85;
var disabled = false;
function shouldConstrain() {
if (disabled) return false;
if (!limit.reachedAny(target.get())) return false;
if (!limit.reachedAny(location.get())) return false;
return true;
}
function constrain(pointerDown) {
if (!shouldConstrain()) return;
var edge = limit.reachedMin(location.get()) ? 'min' : 'max';
var diffToEdge = mathAbs(limit[edge] - location.get());
var diffToTarget = target.get() - location.get();
var friction = Math.min(diffToEdge / edgeOffsetTolerance, maxFriction);
target.subtract(diffToTarget * friction);
if (!pointerDown && mathAbs(diffToTarget) < pullBackThreshold) {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
}
}
function toggleActive(active) {
disabled = !active;
}
var self = {
constrain: constrain,
toggleActive: toggleActive
};
return self;
}
function ScrollContain(viewSize, contentSize, snaps, snapsAligned, containScroll) {
var scrollBounds = Limit(-contentSize + viewSize, snaps[0]);
var snapsBounded = snapsAligned.map(scrollBounds.constrain);
var snapsContained = measureContained();
function findDuplicates() {
var startSnap = snapsBounded[0];
var endSnap = arrayLast(snapsBounded);
var min = snapsBounded.lastIndexOf(startSnap);
var max = snapsBounded.indexOf(endSnap) + 1;
return Limit(min, max);
}
function measureContained() {
if (contentSize <= viewSize) return [scrollBounds.max];
if (containScroll === 'keepSnaps') return snapsBounded;
var _a = findDuplicates(),
min = _a.min,
max = _a.max;
return snapsBounded.slice(min, max);
}
var self = {
snapsContained: snapsContained
};
return self;
}
function ScrollLimit(contentSize, scrollSnaps, loop) {
var limit = measureLimit();
function measureLimit() {
var startSnap = scrollSnaps[0];
var endSnap = arrayLast(scrollSnaps);
var min = loop ? startSnap - contentSize : endSnap;
var max = startSnap;
return Limit(min, max);
}
var self = {
limit: limit
};
return self;
}
function ScrollLooper(contentSize, pxToPercent, limit, location, vectors) {
var min = limit.min + pxToPercent.measure(0.1);
var max = limit.max + pxToPercent.measure(0.1);
var _a = Limit(min, max),
reachedMin = _a.reachedMin,
reachedMax = _a.reachedMax;
function shouldLoop(direction) {
if (direction === 1) return reachedMax(location.get());
if (direction === -1) return reachedMin(location.get());
return false;
}
function loop(direction) {
if (!shouldLoop(direction)) return;
var loopDistance = contentSize * (direction * -1);
vectors.forEach(function (v) {
return v.add(loopDistance);
});
}
var self = {
loop: loop
};
return self;
}
function ScrollProgress(limit) {
var max = limit.max,
scrollLength = limit.length;
function get(n) {
var currentLocation = n - max;
return currentLocation / -scrollLength;
}
var self = {
get: get
};
return self;
}
function ScrollSnap(axis, alignment, pxToPercent, containerRect, slideRects, slidesToScroll) {
var startEdge = axis.startEdge,
endEdge = axis.endEdge;
var snaps = measureUnaligned();
var snapsAligned = measureAligned();
function measureSizes() {
return arrayGroup(slideRects, slidesToScroll).map(function (rects) {
return arrayLast(rects)[endEdge] - rects[0][startEdge];
}).map(pxToPercent.measure).map(mathAbs);
}
function measureUnaligned() {
return slideRects.map(function (rect) {
return containerRect[startEdge] - rect[startEdge];
}).map(pxToPercent.measure).map(function (snap) {
return -mathAbs(snap);
});
}
function measureAligned() {
var groupedSnaps = arrayGroup(snaps, slidesToScroll).map(function (g) {
return g[0];
});
var alignments = measureSizes().map(alignment.measure);
return groupedSnaps.map(function (snap, index) {
return snap + alignments[index];
});
}
var self = {
snaps: snaps,
snapsAligned: snapsAligned
};
return self;
}
function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
var reachedAny = limit.reachedAny,
removeOffset = limit.removeOffset,
constrain = limit.constrain;
function minDistance(d1, d2) {
return mathAbs(d1) < mathAbs(d2) ? d1 : d2;
}
function findTargetSnap(target) {
var distance = loop ? removeOffset(target) : constrain(target);
var ascDiffsToSnaps = scrollSnaps.map(function (scrollSnap) {
return scrollSnap - distance;
}).map(function (diffToSnap) {
return shortcut(diffToSnap, 0);
}).map(function (diff, i) {
return {
diff: diff,
index: i
};
}).sort(function (d1, d2) {
return mathAbs(d1.diff) - mathAbs(d2.diff);
});
var index = ascDiffsToSnaps[0].index;
return {
index: index,
distance: distance
};
}
function shortcut(target, direction) {
var t1 = target;
var t2 = target + contentSize;
var t3 = target - contentSize;
if (!loop) return t1;
if (!direction) return minDistance(minDistance(t1, t2), t3);
var shortest = minDistance(t1, direction === 1 ? t2 : t3);
return mathAbs(shortest) * direction;
}
function byIndex(index, direction) {
var diffToSnap = scrollSnaps[index] - targetVector.get();
var distance = shortcut(diffToSnap, direction);
return {
index: index,
distance: distance
};
}
function byDistance(distance, snap) {
var target = targetVector.get() + distance;
var _a = findTargetSnap(target),
index = _a.index,
targetSnapDistance = _a.distance;
var reachedBound = !loop && reachedAny(target);
if (!snap || reachedBound) return {
index: index,
distance: distance
};
var diffToSnap = scrollSnaps[index] - targetSnapDistance;
var snapDistance = distance + shortcut(diffToSnap, 0);
return {
index: index,
distance: snapDistance
};
}
var self = {
byDistance: byDistance,
byIndex: byIndex,
shortcut: shortcut
};
return self;
}
function ScrollTo(animation, indexCurrent, indexPrevious, scrollTarget, targetVector, events) {
function scrollTo(target) {
var distanceDiff = target.distance;
var indexDiff = target.index !== indexCurrent.get();
if (distanceDiff) {
animation.start();
targetVector.add(distanceDiff);
}
if (indexDiff) {
indexPrevious.set(indexCurrent.get());
indexCurrent.set(target.index);
events.emit('select');
}
}
function distance(n, snap) {
var target = scrollTarget.byDistance(n, snap);
scrollTo(target);
}
function index(n, direction) {
var targetIndex = indexCurrent.clone().set(n);
var target = scrollTarget.byIndex(targetIndex.get(), direction);
scrollTo(target);
}
var self = {
distance: distance,
index: index
};
return self;
}
function SlideLooper(axis, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, scrollLocation, slides) {
var ascItems = arrayKeys(slideSizesWithGaps);
var descItems = arrayKeys(slideSizesWithGaps).reverse();
var loopPoints = startPoints().concat(endPoints());
function removeSlideSizes(indexes, from) {
return indexes.reduce(function (a, i) {
return a - slideSizesWithGaps[i];
}, from);
}
function slidesInGap(indexes, gap) {
return indexes.reduce(function (a, i) {
var remainingGap = removeSlideSizes(a, gap);
return remainingGap > 0 ? a.concat([i]) : a;
}, []);
}
function findLoopPoints(indexes, edge) {
var isStartEdge = edge === 'start';
var offset = isStartEdge ? -contentSize : contentSize;
var slideBounds = slidesInView.findSlideBounds([offset]);
return indexes.map(function (index) {
var initial = isStartEdge ? 0 : -contentSize;
var altered = isStartEdge ? contentSize : 0;
var bounds = slideBounds.filter(function (b) {
return b.index === index;
})[0];
var point = bounds[isStartEdge ? 'end' : 'start'];
var getTarget = function () {
return scrollLocation.get() > point ? initial : altered;
};
return {
point: point,
getTarget: getTarget,
index: index,
location: -1
};
});
}
function startPoints() {
var gap = scrollSnaps[0] - 1;
var indexes = slidesInGap(descItems, gap);
return findLoopPoints(indexes, 'end');
}
function endPoints() {
var gap = viewSize - scrollSnaps[0] - 1;
var indexes = slidesInGap(ascItems, gap);
return findLoopPoints(indexes, 'start');
}
function canLoop() {
return loopPoints.every(function (_a) {
var index = _a.index;
var otherIndexes = ascItems.filter(function (i) {
return i !== index;
});
return removeSlideSizes(otherIndexes, viewSize) <= 0;
});
}
function loop() {
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;
}
});
}
function clear() {
loopPoints.forEach(function (_a) {
var index = _a.index;
slides[index].style[axis.startEdge] = '';
});
}
var self = {
canLoop: canLoop,
clear: clear,
loop: loop,
loopPoints: loopPoints
};
return self;
}
function SlidesInView(viewSize, contentSize, slideSizes, snaps, limit, loop, inViewThreshold) {
var removeOffset = limit.removeOffset,
constrain = limit.constrain;
var cachedThreshold = Math.min(Math.max(inViewThreshold, 0.01), 0.99);
var cachedOffsets = loop ? [0, contentSize, -contentSize] : [0];
var cachedBounds = findSlideBounds(cachedOffsets, cachedThreshold);
function findSlideBounds(offsets, threshold) {
var slideOffsets = offsets || cachedOffsets;
var slideThreshold = threshold || 0;
var thresholds = slideSizes.map(function (s) {
return s * slideThreshold;
});
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,
index: index
};
});
return list.concat(bounds);
}, []);
}
function check(location, bounds) {
var limitedLocation = loop ? removeOffset(location) : constrain(location);
var slideBounds = bounds || cachedBounds;
return slideBounds.reduce(function (list, slideBound) {
var index = slideBound.index,
start = slideBound.start,
end = slideBound.end;
var inList = list.indexOf(index) !== -1;
var inView = start < limitedLocation && end > limitedLocation;
return !inList && inView ? list.concat([index]) : list;
}, []);
}
var self = {
check: check,
findSlideBounds: findSlideBounds
};
return self;
}
function SlideSizes(axis, pxToPercent, slides, slideRects, loop) {
var measureSize = axis.measureSize,
startEdge = axis.startEdge,
endEdge = axis.endEdge;
var sizesInPx = slideRects.map(measureSize);
var slideSizes = sizesInPx.map(pxToPercent.measure);
var slideSizesWithGaps = measureWithGaps();
function measureWithGaps() {
return slideRects.map(function (rect, index, rects) {
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);
return rects[index + 1][startEdge] - rect[startEdge];
}).map(pxToPercent.measure).map(mathAbs);
}
var self = {
slideSizes: slideSizes,
slideSizesWithGaps: slideSizesWithGaps
};
return self;
}
function Translate(axis, direction, container) {
var translate = axis.scroll === 'x' ? x : y;
var containerStyle = container.style;
var disabled = false;
function x(n) {
return "translate3d(" + n + "%,0px,0px)";
}
function y(n) {
return "translate3d(0px," + n + "%,0px)";
}
function to(target) {
if (disabled) return;
containerStyle.transform = translate(direction.apply(target.get()));
}
function toggleActive(active) {
disabled = !active;
}
function clear() {
containerStyle.transform = '';
}
var self = {
clear: clear,
to: to,
toggleActive: toggleActive
};
return self;
}
function Engine(root, container, slides, options, events) {
// Options
var align = options.align,
scrollAxis = options.axis,
contentDirection = options.direction,
startIndex = options.startIndex,
inViewThreshold = options.inViewThreshold,
loop = options.loop,
speed = options.speed,
dragFree = options.dragFree,
slidesToScroll = options.slidesToScroll,
skipSnaps = options.skipSnaps,
containScroll = options.containScroll; // Measurements
var containerRect = container.getBoundingClientRect();
var slideRects = slides.map(function (slide) {
return slide.getBoundingClientRect();
});
var direction = Direction(contentDirection);
var axis = Axis(scrollAxis, contentDirection);
var pxToPercent = PxToPercent(axis.measureSize(containerRect));
var viewSize = pxToPercent.totalPercent;
var alignment = Alignment(align, viewSize);
var _a = SlideSizes(axis, pxToPercent, slides, slideRects, loop),
slideSizes = _a.slideSizes,
slideSizesWithGaps = _a.slideSizesWithGaps;
var _b = ScrollSnap(axis, alignment, pxToPercent, containerRect, slideRects, slidesToScroll),
snaps = _b.snaps,
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 limit = ScrollLimit(contentSize, scrollSnaps, loop).limit; // Indexes
var index = Counter(arrayLastIndex(scrollSnaps), startIndex, loop);
var indexPrevious = index.clone();
var slideIndexes = arrayKeys(slides); // Draw
var update = function () {
if (!loop) engine.scrollBounds.constrain(engine.dragHandler.pointerDown());
engine.scrollBody.seek(target).update();
var settled = engine.scrollBody.settle(target);
if (settled && !engine.dragHandler.pointerDown()) {
engine.animation.stop();
events.emit('settle');
}
if (!settled) {
events.emit('scroll');
}
if (loop) {
engine.scrollLooper.loop(engine.scrollBody.direction());
engine.slideLooper.loop();
}
engine.translate.to(location);
engine.animation.proceed();
}; // Shared
var animation = Animation(update);
var startLocation = scrollSnaps[index.get()];
var location = Vector1D(startLocation);
var target = Vector1D(startLocation);
var scrollBody = ScrollBody(location, speed, 1);
var scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
var scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, events);
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 engine = {
containerRect: containerRect,
slideRects: slideRects,
animation: animation,
axis: axis,
direction: direction,
dragHandler: dragHandler,
eventStore: EventStore(),
pxToPercent: pxToPercent,
index: index,
indexPrevious: indexPrevious,
limit: limit,
location: location,
options: options,
scrollBody: scrollBody,
scrollBounds: ScrollBounds(limit, location, target, scrollBody),
scrollLooper: ScrollLooper(contentSize, pxToPercent, limit, location, [location, target]),
scrollProgress: ScrollProgress(limit),
scrollSnaps: scrollSnaps,
scrollTarget: scrollTarget,
scrollTo: scrollTo,
slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, location, slides),
slidesInView: slidesInView,
slideIndexes: slideIndexes,
target: target,
translate: Translate(axis, direction, container)
};
return engine;
}
function EventEmitter() {
var listeners = {};
function getListeners(evt) {
return listeners[evt] || [];
}
function emit(evt) {
getListeners(evt).forEach(function (e) {
return e(evt);
});
return self;
}
function on(evt, cb) {
listeners[evt] = getListeners(evt).concat([cb]);
return self;
}
function off(evt, cb) {
listeners[evt] = getListeners(evt).filter(function (e) {
return e !== cb;
});
return self;
}
var self = {
emit: emit,
off: off,
on: on
};
return self;
}
var defaultOptions = {
align: 'center',
axis: 'x',
containScroll: '',
direction: 'ltr',
dragFree: false,
draggable: true,
inViewThreshold: 0,
loop: false,
skipSnaps: false,
slidesToScroll: 1,
speed: 10,
startIndex: 0
};
function OptionsPseudo(node) {
var pseudoString = getComputedStyle(node, ':before').content;
function get() {
try {
return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, ''));
} catch (error) {} // eslint-disable-line no-empty
return {};
}
var self = {
get: get
};
return self;
}
function EmblaCarousel(nodes, userOptions, userPlugins) {
var events = EventEmitter();
var debouncedResize = debounce(resize, 500);
var reInit = reActivate;
var on = events.on,
off = events.off;
var engine;
var activated = false;
var optionsBase = Object.assign({}, defaultOptions, EmblaCarousel.globalOptions);
var options = Object.assign({}, optionsBase);
var optionsPseudo;
var plugins;
var rootSize = 0;
var root;
var container;
var slides;
function setupElements() {
var providedContainer = 'container' in nodes && nodes.container;
var providedSlides = 'slides' in nodes && nodes.slides;
root = 'root' in nodes ? nodes.root : nodes;
container = providedContainer || root.children[0];
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);
engine.translate.to(engine.location);
rootSize = engine.axis.measureSize(root.getBoundingClientRect());
plugins.forEach(function (plugin) {
return plugin.init(self);
});
if (options.loop) {
if (!engine.slideLooper.canLoop()) {
deActivate();
return activate({
loop: false
}, withPlugins);
}
engine.slideLooper.loop();
}
if (options.draggable && container.offsetParent && slides.length) {
engine.dragHandler.addActivationEvents();
}
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({
startIndex: startIndex
}, withOptions);
deActivate();
activate(newOptions, withPlugins || plugins);
events.emit('reInit');
}
function deActivate() {
engine.dragHandler.removeAllEvents();
engine.animation.stop();
engine.eventStore.removeAll();
engine.translate.clear();
engine.slideLooper.clear();
plugins.forEach(function (plugin) {
return plugin.destroy();
});
}
function destroy() {
if (!activated) return;
deActivate();
activated = false;
events.emit('destroy');
}
function resize() {
if (!activated) return;
var size = engine.axis.measureSize(root.getBoundingClientRect());
if (rootSize !== size) reActivate();
events.emit('resize');
}
function slidesInView(target) {
var location = engine[target ? 'target' : 'location'].get();
var type = options.loop ? 'removeOffset' : 'constrain';
return engine.slidesInView.check(engine.limit[type](location));
}
function slidesNotInView(target) {
var inView = slidesInView(target);
return engine.slideIndexes.filter(function (index) {
return inView.indexOf(index) === -1;
});
}
function scrollTo(index, jump, direction) {
engine.scrollBody.useBaseMass().useSpeed(jump ? 100 : options.speed);
if (activated) engine.scrollTo.index(index, direction || 0);
}
function scrollNext(jump) {
var next = engine.index.clone().add(1);
scrollTo(next.get(), jump === true, -1);
}
function scrollPrev(jump) {
var prev = engine.index.clone().add(-1);
scrollTo(prev.get(), jump === true, 1);
}
function canScrollNext() {
var next = engine.index.clone().add(1);
return next.get() !== selectedScrollSnap();
}
function canScrollPrev() {
var prev = engine.index.clone().add(-1);
return prev.get() !== selectedScrollSnap();
}
function scrollSnapList() {
return engine.scrollSnaps.map(engine.scrollProgress.get);
}
function scrollProgress() {
return engine.scrollProgress.get(engine.location.get());
}
function selectedScrollSnap() {
return engine.index.get();
}
function previousScrollSnap() {
return engine.indexPrevious.get();
}
function clickAllowed() {
return engine.dragHandler.clickAllowed();
}
function internalEngine() {
return engine;
}
function rootNode() {
return root;
}
function containerNode() {
return container;
}
function slideNodes() {
return slides;
}
var self = {
canScrollNext: canScrollNext,
canScrollPrev: canScrollPrev,
clickAllowed: clickAllowed,
containerNode: containerNode,
internalEngine: internalEngine,
destroy: destroy,
off: off,
on: on,
previousScrollSnap: previousScrollSnap,
reInit: reInit,
rootNode: rootNode,
scrollNext: scrollNext,
scrollPrev: scrollPrev,
scrollProgress: scrollProgress,
scrollSnapList: scrollSnapList,
scrollTo: scrollTo,
selectedScrollSnap: selectedScrollSnap,
slideNodes: slideNodes,
slidesInView: slidesInView,
slidesNotInView: slidesNotInView
};
activate(userOptions, userPlugins);
return self;
}
EmblaCarousel.globalOptions = undefined;
function useEmblaCarousel(options, plugins) {

@@ -1500,2 +18,6 @@ if (options === void 0) {

var optionsHandler = useRef(EmblaCarousel.optionsHandler());
var storedOptions = useRef(options);
var storedPlugins = useRef(plugins);
var _a = useState(),

@@ -1509,22 +31,6 @@ embla = _a[0],

var storedOptions = useRef(options);
var storedPlugins = useRef(plugins);
var activeOptions = useMemo(function () {
if (!areObjectsEqualShallow(storedOptions.current, options)) {
storedOptions.current = options;
}
return storedOptions.current;
}, [storedOptions, options]);
var activePlugins = useMemo(function () {
if (!arePluginsEqual(storedPlugins.current, plugins)) {
storedPlugins.current = plugins;
}
return storedPlugins.current;
}, [storedPlugins, plugins]);
useEffect(function () {
if (canUseDOM() && viewport) {
EmblaCarousel.globalOptions = useEmblaCarousel.globalOptions;
var newEmbla_1 = EmblaCarousel(viewport, activeOptions, activePlugins);
var newEmbla_1 = EmblaCarousel(viewport, storedOptions.current, storedPlugins.current);
setEmbla(newEmbla_1);

@@ -1537,3 +43,10 @@ return function () {

}
}, [viewport, activeOptions, activePlugins, setEmbla]);
}, [viewport, setEmbla]);
useEffect(function () {
if (!embla) return;
if (optionsHandler.current.areEqual(storedOptions.current, options)) return;
storedOptions.current = options;
storedPlugins.current = plugins;
embla.reInit(storedOptions.current, storedPlugins.current);
}, [embla, options, plugins]);
return [setViewport, embla];

@@ -1544,3 +57,3 @@ }

export default useEmblaCarousel;
export { useEmblaCarousel as default };
//# sourceMappingURL=embla-carousel-react.esm.js.map

@@ -1,1 +0,1 @@

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselReact=e(n.React)}(this,(function(n){"use strict";function e(n,e){return Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every((function(t){return!!Object.prototype.hasOwnProperty.call(e,t)&&n[t]===e[t]}))}function t(n){return n.concat().sort((function(n,e){return n.name>e.name?1:-1})).map((function(n){return n.options}))}function r(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 o(n){return Math.abs(n)}function i(n){return n?n/o(n):0}function u(n,e){return o(n-e)}function c(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function a(n){return Object.keys(n).map(Number)}function s(n){return n[f(n)]}function f(n){return Math.max(0,n.length-1)}function d(n,e){var t=o(n-e);function r(e){return e<n}function i(n){return n>e}function u(n){return r(n)||i(n)}return{length:t,max:e,min:n,constrain:function(t){return u(t)?r(t)?n:e:t},reachedAny:u,reachedMax:i,reachedMin:r,removeOffset:function(n){return t?n-t*Math.ceil((n-e)/t):n}}}function l(n,e,t){var r=d(0,n),i=r.min,u=r.constrain,c=n+1,a=s(e);function s(n){return t?o((c+n)%c):u(n)}function f(){return a}function p(n){return a=s(n),m}var m={add:function(n){return p(f()+n)},clone:function(){return l(n,f(),t)},get:f,set:p,min:i,max:n};return m}function p(){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 m(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 v(n,e,t,r,c,a,s,f,d,l,v,g,x,h,y){var S=n.cross,b=["INPUT","SELECT","TEXTAREA"],w=m(0),E=p(),O=p(),A={mouse:300,touch:400},M={mouse:500,touch:600},T=c?5:16,P=0,B=0,I=!1,k=!1,z=!1,D=!1;function L(n){if(!(D="mousedown"===n.type)||0===n.button){var e,o,i=u(r.get(),s.get())>=2,c=D||!i,f=(e=n.target,o=e.nodeName||"",!(b.indexOf(o)>-1)),d=i||D&&f;I=!0,a.pointerDown(n),w.set(r),r.set(s),l.useBaseMass().useSpeed(80),function(){var n=D?document:t;O.add(n,"touchmove",j).add(n,"touchend",N).add(n,"mousemove",j).add(n,"mouseup",N)}(),P=a.readPoint(n),B=a.readPoint(n,S),x.emit("pointerDown"),c&&(z=!1),d&&n.preventDefault()}}function j(n){if(!k&&!D){if(!n.cancelable)return N(n);var t=a.readPoint(n),o=a.readPoint(n,S),i=u(t,P),c=u(o,B);if(!(k=i>c)&&!z)return N(n)}var s=a.pointerMove(n);!z&&s&&(z=!0),f.start(),r.add(e.apply(s)),n.preventDefault()}function N(n){var t=v.byDistance(0,!1).index!==g.get(),s=a.pointerUp(n)*(c?M:A)[D?"mouse":"touch"],f=function(n,e){var t=g.clone().add(-1*i(n)),r=t.get()===g.min||t.get()===g.max,u=v.byDistance(n,!c).distance;return c||o(n)<20?u:!h&&r?.4*u:y&&e?.5*u:v.byIndex(t.get(),0).distance}(e.apply(s),t),p=function(n,e){if(0===n||0===e)return 0;if(o(n)<=o(e))return 0;var t=u(o(n),o(e));return o(t/n)}(s,f),m=u(r.get(),w.get())>=.5,S=t&&p>.75,b=o(s)<20,E=S?10:T,P=S?1+2.5*p:1;m&&!D&&(z=!0),k=!1,I=!1,O.removeAll(),l.useSpeed(b?9:E).useMass(P),d.distance(f,!c),D=!1,x.emit("pointerUp")}function R(n){z&&n.preventDefault()}return{addActivationEvents:function(){var n=t;E.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",L).add(n,"mousedown",L).add(n,"touchcancel",N).add(n,"contextmenu",N).add(n,"click",R)},clickAllowed:function(){return!z},pointerDown:function(){return I},removeAllEvents:function(){E.removeAll(),O.removeAll()}}}function g(n,e,t){var r,o,u=(r=2,o=Math.pow(10,r),function(n){return Math.round(n*o)/o}),c=m(0),a=m(0),s=m(0),f=0,d=e,l=t;function p(n){return d=n,g}function v(n){return l=n,g}var g={direction:function(){return f},seek:function(e){s.set(e).subtract(n);var t,r,o,u,p=(t=s.get(),(o=0)+(t-(r=0))/(100-r)*(d-o));return f=i(s.get()),s.normalize().multiply(p).subtract(c),(u=s).divide(l),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(t)},useBaseSpeed:function(){return p(e)},useMass:v,useSpeed:p};return g}function x(n,e,t,r){var i=!1;return{constrain:function(u){if(!i&&n.reachedAny(t.get())&&n.reachedAny(e.get())){var c=n.reachedMin(e.get())?"min":"max",a=o(n[c]-e.get()),s=t.get()-e.get(),f=Math.min(a/50,.85);t.subtract(s*f),!u&&o(s)<10&&(t.set(n.constrain(t.get())),r.useSpeed(10).useMass(3))}},toggleActive:function(n){i=!n}}}function h(n,e,t,r,o){var i=d(-e+n,t[0]),u=r.map(i.constrain);return{snapsContained:function(){if(e<=n)return[i.max];if("keepSnaps"===o)return u;var t=function(){var n=u[0],e=s(u),t=u.lastIndexOf(n),r=u.indexOf(e)+1;return d(t,r)}(),r=t.min,c=t.max;return u.slice(r,c)}()}}function y(n,e,t,r,o){var i=d(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 S(n){var e=n.max,t=n.length;return{get:function(n){return(n-e)/-t}}}function b(n,e,t,r,i,u){var a,f,d=n.startEdge,l=n.endEdge,p=i.map((function(n){return r[d]-n[d]})).map(t.measure).map((function(n){return-o(n)})),m=(a=c(p,u).map((function(n){return n[0]})),f=c(i,u).map((function(n){return s(n)[l]-n[0][d]})).map(t.measure).map(o).map(e.measure),a.map((function(n,e){return n+f[e]})));return{snaps:p,snapsAligned:m}}function w(n,e,t,r,i){var u=r.reachedAny,c=r.removeOffset,a=r.constrain;function s(n,e){return o(n)<o(e)?n:e}function f(e,r){var i=e,u=e+t,c=e-t;return n?r?o(s(i,1===r?u:c))*r:s(s(i,u),c):i}return{byDistance:function(t,r){var s=i.get()+t,d=function(t){var r=n?c(t):a(t);return{index:e.map((function(n){return n-r})).map((function(n){return f(n,0)})).map((function(n,e){return{diff:n,index:e}})).sort((function(n,e){return o(n.diff)-o(e.diff)}))[0].index,distance:r}}(s),l=d.index,p=d.distance,m=!n&&u(s);return!r||m?{index:l,distance:t}:{index:l,distance:t+f(e[l]-p,0)}},byIndex:function(n,t){return{index:n,distance:f(e[n]-i.get(),t)}},shortcut:f}}function E(n,e,t,r,o,i,u,c){var s,f=a(r),d=a(r).reverse(),l=(s=o[0]-1,v(m(d,s),"end")).concat(function(){var n=e-o[0]-1;return v(m(f,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,c=i.findSlideBounds([o]);return n.map((function(n){var e=r?0:-t,o=r?t:0,i=c.filter((function(e){return e.index===n}))[0][r?"end":"start"];return{point:i,getTarget:function(){return u.get()>i?e:o},index:n,location:-1}}))}return{canLoop:function(){return l.every((function(n){var t=n.index;return p(f.filter((function(n){return n!==t})),e)<=0}))},clear:function(){l.forEach((function(e){var t=e.index;c[t].style[n.startEdge]=""}))},loop:function(){l.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,i=t();i!==r&&(c[o].style[n.startEdge]=i+"%",e.location=i)}))},loopPoints:l}}function O(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 A(n,e,t,i,u){var c,A=i.align,M=i.axis,T=i.direction,P=i.startIndex,B=i.inViewThreshold,I=i.loop,k=i.speed,z=i.dragFree,D=i.slidesToScroll,L=i.skipSnaps,j=i.containScroll,N=e.getBoundingClientRect(),R=t.map((function(n){return n.getBoundingClientRect()})),C=function(n){var e="rtl"===n?-1:1;return{apply:function(n){return n*e}}}(T),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,T),H=(c=V.measureSize(N),{measure:function(n){return 0===c?0:n/c*100},totalPercent:100}),F=H.totalPercent,U=r(A,F),q=function(n,e,t,r,i){var u=n.measureSize,c=n.startEdge,a=n.endEdge,d=r.map(u);return{slideSizes:d.map(e.measure),slideSizesWithGaps:r.map((function(n,e,r){var o=e===f(r),u=window.getComputedStyle(s(t)),l=parseFloat(u.getPropertyValue("margin-"+a));return o?d[e]+(i?l:0):r[e+1][c]-n[c]})).map(e.measure).map(o)}}(V,H,t,R,I),G=q.slideSizes,W=q.slideSizesWithGaps,X=b(V,U,H,N,R,D),J=X.snaps,Y=X.snapsAligned,K=-s(J)+s(W),Q=h(F,K,J,Y,j).snapsContained,Z=!I&&""!==j?Q:Y,$=function(n,e,t){var r,o;return{limit:(r=e[0],o=s(e),d(t?r-n:o,r))}}(K,Z,I).limit,_=l(f(Z),P,I),nn=_.clone(),en=a(t),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||dn.scrollBounds.constrain(dn.dragHandler.pointerDown()),dn.scrollBody.seek(un).update();var n=dn.scrollBody.settle(un);n&&!dn.dragHandler.pointerDown()&&(dn.animation.stop(),u.emit("settle")),n||u.emit("scroll"),I&&(dn.scrollLooper.loop(dn.scrollBody.direction()),dn.slideLooper.loop()),dn.translate.to(on),dn.animation.proceed()})),rn=Z[_.get()],on=m(rn),un=m(rn),cn=g(on,k,1),an=w(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,u),fn=function(n,e,t,r,o,i,u){var c=o.removeOffset,a=o.constrain,s=Math.min(Math.max(u,.01),.99),f=i?[0,e,-e]:[0],d=l(f,s);function l(e,o){var i=e||f,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||d).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,G,J,$,I,B),dn={containerRect:N,slideRects:R,animation:tn,axis:V,direction:C,dragHandler:v(V,C,n,un,z,function(n,e){var t,r;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 t=n,r=n,e.measure(c(n))},pointerMove:function(n){var o=c(n)-c(r),i=u(n)-u(t)>170;return r=n,i&&(t=n),e.measure(o)},pointerUp:function(n){if(!t||!r)return 0;var i=c(r)-c(t),a=u(n)-u(t),s=u(n)-u(r)>170,f=i/a;return a&&!s&&o(f)>.1?e.measure(f):0},readPoint:c}}(V,H),on,tn,sn,cn,an,_,u,I,L),eventStore:p(),pxToPercent:H,index:_,indexPrevious:nn,limit:$,location:on,options:i,scrollBody:cn,scrollBounds:x($,on,un,cn),scrollLooper:y(K,H,$,on,[on,un]),scrollProgress:S($),scrollSnaps:Z,scrollTarget:an,scrollTo:sn,slideLooper:E(V,F,K,W,Z,fn,on,t),slidesInView:fn,slideIndexes:en,target:un,translate:O(V,C,e)};return dn}var M={align:"center",axis:"x",containScroll:"",direction:"ltr",dragFree:!1,draggable:!0,inViewThreshold:0,loop:!1,skipSnaps:!1,slidesToScroll:1,speed:10,startIndex:0};function T(n,e,t){var r,o,i,u,c,a,s,f,d,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&&E(),l.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),m=E,v=l.on,g=l.off,x=!1,h=Object.assign({},M,T.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,f=t||s.children[0],d=r||[].slice.call(f.children),e=getComputedStyle(s,":before").content,c={get:function(){try{return JSON.parse(e.slice(1,-1).replace(/\\/g,""))}catch(n){}return{}}}}function w(n,e){if(b(),h=Object.assign({},h,n),y=Object.assign({},h,c.get()),a=Object.assign([],e),(u=A(s,f,d,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(k)})),y.loop){if(!u.slideLooper.canLoop())return O(),w({loop:!1},e);u.slideLooper.loop()}y.draggable&&f.offsetParent&&d.length&&u.dragHandler.addActivationEvents(),x||(setTimeout((function(){return l.emit("init")}),0),x=!0)}function E(n,e){if(x){var t=I(),r=Object.assign({startIndex:t},n);O(),w(r,e||a),l.emit("reInit")}}function O(){u.dragHandler.removeAllEvents(),u.animation.stop(),u.eventStore.removeAll(),u.translate.clear(),u.slideLooper.clear(),a.forEach((function(n){return n.destroy()}))}function P(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 k={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 f},internalEngine:function(){return u},destroy:function(){x&&(O(),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 d},slidesInView:P,slidesNotInView:function(n){var e=P(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}};return w(e,t),k}function P(r,o){void 0===r&&(r={}),void 0===o&&(o=[]);var i=n.useState(),u=i[0],c=i[1],a=n.useState(),s=a[0],f=a[1],d=n.useRef(r),l=n.useRef(o),p=n.useMemo((function(){return e(d.current,r)||(d.current=r),d.current}),[d,r]),m=n.useMemo((function(){return function(n,r){if(n.length!==r.length)return!1;var o=t(n),i=t(r);return o.every((function(n,t){return e(n,i[t])}))}(l.current,o)||(l.current=o),l.current}),[l,o]);return n.useEffect((function(){if("undefined"!=typeof window&&window.document&&window.document.createElement&&s){T.globalOptions=P.globalOptions;var n=T(s,p,m);return c(n),function(){return n.destroy()}}c(void 0)}),[s,p,m,c]),[f,u]}return T.globalOptions=void 0,P.globalOptions=void 0,P}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("embla-carousel")):"function"==typeof define&&define.amd?define(["react","embla-carousel"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).EmblaCarouselReact=t(e.React,e.EmblaCarousel)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=n(t);function r(t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var o=e.useRef(u.default.optionsHandler()),f=e.useRef(t),i=e.useRef(n),a=e.useState(),c=a[0],l=a[1],d=e.useState(),s=d[0],p=d[1];return e.useEffect((function(){if("undefined"!=typeof window&&window.document&&window.document.createElement&&s){u.default.globalOptions=r.globalOptions;var e=u.default(s,f.current,i.current);return l(e),function(){return e.destroy()}}l(void 0)}),[s,l]),e.useEffect((function(){c&&(o.current.areEqual(f.current,t)||(f.current=t,i.current=n,c.reInit(f.current,i.current)))}),[c,t,n]),[p,c]}return r.globalOptions=void 0,r}));
export { EmblaOptionsType } from 'embla-carousel/components/Options';
export { EmblaEventType } from 'embla-carousel/components/EventEmitter';
export { EmblaCarouselType, EmblaPluginType } from 'embla-carousel/components';
export { EmblaEventType } from 'embla-carousel/components/EventHandler';
export { EmblaPluginType } from 'embla-carousel/components/Plugins';
export { EmblaCarouselType } from 'embla-carousel/components';
export { UseEmblaCarouselType } from './components';
export { default } from './components';
{
"name": "embla-carousel-react",
"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-react.umd.js",
"unpkg": "embla-carousel-react.umd.js",
"main": "embla-carousel-react.cjs.js",
"module": "embla-carousel-react.esm.js",
"browser": "embla-carousel-react.umd.js",
"types": "index.d.ts",

@@ -45,21 +46,21 @@ "sideEffects": false,

"devDependencies": {
"@types/jest": "^26.0.22",
"@types/react": "^17.0.2",
"@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",
"@types/react": "^18.0.8",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"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"
},
"dependencies": {
"embla-carousel": "6.2.0"
"embla-carousel": "7.0.0-rc01"
},
"peerDependencies": {
"react": "^17.0.2"
"react": "^18.1.0"
}
}
}

@@ -11,3 +11,3 @@ <br />

<a href="https://www.npmjs.com/package/embla-carousel-react"><img src="https://img.shields.io/npm/v/embla-carousel-react.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>

@@ -52,4 +52,4 @@ <a href="https://bundlephobia.com/result?p=embla-carousel-react@latest"><img src="https://img.shields.io/bundlephobia/minzip/embla-carousel-react?color=%238ab4f8&label=gzip%20size">

<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>

@@ -56,0 +56,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc