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

embla-carousel

Package Overview
Dependencies
Maintainers
1
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embla-carousel - npm Package Compare versions

Comparing version 2.8.0 to 2.8.1

2

lib/components/dragHandler.d.ts
import { Animation } from './animation';
import { Counter } from './counter';
import { Direction } from './direction';
import { DragTracker } from './dragTracker';

@@ -28,3 +27,2 @@ import { EventDispatcher } from './eventDispatcher';

clickAllowed: () => boolean;
direction: Direction;
pointerDown: () => boolean;

@@ -31,0 +29,0 @@ removeAllEvents: () => void;

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

import { Direction } from './direction';
import { PxToPercent } from './pxToPercent';

@@ -6,3 +5,2 @@ import { Vector1D } from './vector1d';

export declare type DragTracker = {
direction: Direction;
pointerDown: (evt: Event) => number;

@@ -9,0 +7,0 @@ pointerMove: (evt: Event) => number;

8

lib/components/scrollBody.d.ts

@@ -12,7 +12,7 @@ import { Direction } from './direction';

update: () => void;
seek: (target: Vector1D) => ScrollBody;
settle: (target: Vector1D) => boolean;
useSpeed: (newSpeed: number) => ScrollBody;
seek: (v: Vector1D) => ScrollBody;
settle: (v: Vector1D) => boolean;
useSpeed: (n: number) => ScrollBody;
useDefaultSpeed: () => ScrollBody;
useMass: (newMass: number) => ScrollBody;
useMass: (n: number) => ScrollBody;
useDefaultMass: () => ScrollBody;

@@ -19,0 +19,0 @@ };

@@ -10,3 +10,2 @@ import { Animation } from './animation';

animation: Animation;
tolerance: number;
};

@@ -13,0 +12,0 @@ export declare type ScrollBounds = {

@@ -9,8 +9,7 @@ import { Limit } from './limit';

pxToPercent: PxToPercent;
vectors: Vector1D[];
};
export declare type ScrollLooper = {
loop: (direction: number) => void;
loop: (vectors: Vector1D[], direction: number) => void;
};
export declare function ScrollLooper(params: Params): ScrollLooper;
export {};

@@ -8,5 +8,5 @@ import { Alignment } from './alignment';

export declare type ScrollSnap = {
measure: (snapSize: number, index: number) => number;
measure: (index: number) => number;
};
export declare function ScrollSnap(params: Params): ScrollSnap;
export {};

@@ -5,3 +5,4 @@ export declare function rectWidth(node: HTMLElement): number;

export declare function debounce(callback: () => void, time: number): () => void;
export declare function groupNumbers(array: number[], size: number): number[][];
export declare function roundToDecimals(decimalPoints: number): (n: number) => number;
export declare function groupArray<GenericType>(array: GenericType[], size: number): GenericType[][];
export declare function arrayKeys<GenericType>(array: GenericType): number[];
export declare type Vector1D = {
get: () => number;
set: (v: Vector1D) => Vector1D;
add: (v: Vector1D) => Vector1D;
subtract: (v: Vector1D) => Vector1D;
set: (v: Vector1D | number) => Vector1D;
add: (v: Vector1D | number) => Vector1D;
subtract: (v: Vector1D | number) => Vector1D;
multiply: (n: number) => Vector1D;
setNumber: (n: number) => Vector1D;
addNumber: (n: number) => Vector1D;
subtractNumber: (n: number) => Vector1D;
divide: (n: number) => Vector1D;
magnitude: () => number;
normalize: () => Vector1D;
};
export declare function Vector1D(value: number): Vector1D;

@@ -109,22 +109,20 @@ (function webpackUniversalModuleDefinition(root, factory) {

function Vector1D(value) {
var state = {
value: value
};
var vector = value;
function get() {
return state.value;
return vector;
}
function set(v) {
state.value = v.get();
function set(n) {
vector = readNumber(n);
return self;
}
function add(v) {
state.value += v.get();
function add(n) {
vector += readNumber(n);
return self;
}
function subtract(v) {
state.value -= v.get();
function subtract(n) {
vector -= readNumber(n);
return self;

@@ -134,3 +132,3 @@ }

function multiply(n) {
state.value *= n;
vector *= n;
return self;

@@ -140,43 +138,23 @@ }

function divide(n) {
state.value /= n;
vector /= n;
return self;
}
function setNumber(n) {
state.value = n;
function normalize() {
if (vector !== 0) divide(vector);
return self;
}
function addNumber(n) {
state.value += n;
return self;
function readNumber(n) {
return typeof n === 'number' ? n : n.get();
}
function subtractNumber(n) {
state.value -= n;
return self;
}
function magnitude() {
return get();
}
function normalize() {
var m = magnitude();
if (m !== 0) divide(m);
return self;
}
var self = {
add: add,
addNumber: addNumber,
divide: divide,
get: get,
magnitude: magnitude,
multiply: multiply,
normalize: normalize,
set: set,
setNumber: setNumber,
subtract: subtract,
subtractNumber: subtractNumber
subtract: subtract
};

@@ -199,67 +177,2 @@ return Object.freeze(self);

function Limit(params) {
var min = params.min,
max = params.max;
var loopLimits = {
min: max,
max: min
};
var constrainLimits = {
min: min,
max: max
};
function reachedMin(n) {
return n < min;
}
function reachedMax(n) {
return n > max;
}
function reachedAny(n) {
return reachedMin(n) || reachedMax(n);
}
function reachedWhich(n) {
var isMin = reachedMin(n) && 'min';
var isMax = reachedMax(n) && 'max';
return isMin || isMax || '';
}
function loop(n) {
var which = reachedWhich(n);
return which ? loopLimits[which] : n;
}
function constrain(n) {
var which = reachedWhich(n);
return which ? constrainLimits[which] : n;
}
var self = {
constrain: constrain,
loop: loop,
max: max,
min: min,
reachedAny: reachedAny,
reachedMax: reachedMax,
reachedMin: reachedMin
};
return Object.freeze(self);
}
exports.Limit = Limit;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function rectWidth(node) {

@@ -295,3 +208,12 @@ return node.getBoundingClientRect().width;

function groupNumbers(array, size) {
function roundToDecimals(decimalPoints) {
var pow = Math.pow(10, decimalPoints);
return function (n) {
return Math.round(n * pow) / pow;
};
}
exports.roundToDecimals = roundToDecimals;
function groupArray(array, size) {
var groups = [];

@@ -306,15 +228,12 @@

exports.groupNumbers = groupNumbers;
exports.groupArray = groupArray;
function roundToDecimals(decimalPoints) {
var pow = Math.pow(10, decimalPoints);
return function (n) {
return Math.round(n * pow) / pow;
};
function arrayKeys(array) {
return Object.keys(array).map(Number);
}
exports.roundToDecimals = roundToDecimals;
exports.arrayKeys = arrayKeys;
/***/ }),
/* 3 */
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

@@ -329,21 +248,50 @@

var vector1d_1 = __webpack_require__(0);
function Limit(params) {
var min = params.min,
max = params.max;
var loopLimits = {
min: max,
max: min
};
var constrainLimits = {
min: min,
max: max
};
function Direction(value) {
var direction = vector1d_1.Vector1D(normalize(value));
var get = direction.get;
function reachedMin(n) {
return n < min;
}
function normalize(n) {
return n === 0 ? 0 : n / Math.abs(n);
function reachedMax(n) {
return n > max;
}
function set(v) {
var d = normalize(v.get());
if (d !== 0) direction.setNumber(d);
return self;
function reachedAny(n) {
return reachedMin(n) || reachedMax(n);
}
function reachedWhich(n) {
if (reachedMin(n)) return 'min';
if (reachedMax(n)) return 'max';
return '';
}
function loop(n) {
var which = reachedWhich(n);
return which ? loopLimits[which] : n;
}
function constrain(n) {
var which = reachedWhich(n);
return which ? constrainLimits[which] : n;
}
var self = {
get: get,
set: set
constrain: constrain,
loop: loop,
max: max,
min: min,
reachedAny: reachedAny,
reachedMax: reachedMax,
reachedMin: reachedMin
};

@@ -353,6 +301,6 @@ return Object.freeze(self);

exports.Direction = Direction;
exports.Limit = Limit;
/***/ }),
/* 4 */
/* 3 */
/***/ (function(module, exports, __webpack_require__) {

@@ -374,12 +322,10 @@

var type = loop ? 'loop' : 'constrain';
var state = {
value: withinLimit(start)
};
var counter = withinLimit(start);
function get() {
return state.value;
return counter;
}
function set(n) {
state.value = withinLimit(n);
counter = withinLimit(n);
return self;

@@ -403,5 +349,4 @@ }

function clone() {
var s = get();
return Counter({
start: s,
start: get(),
limit: limit,

@@ -426,2 +371,38 @@ loop: loop

/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var vector1d_1 = __webpack_require__(0);
function Direction(value) {
var direction = vector1d_1.Vector1D(normalize(value));
var get = direction.get;
function normalize(n) {
return n === 0 ? 0 : n / Math.abs(n);
}
function set(v) {
var d = normalize(v.get());
if (d !== 0) direction.set(d);
return self;
}
var self = {
get: get,
set: set
};
return Object.freeze(self);
}
exports.Direction = Direction;
/***/ }),
/* 5 */

@@ -438,5 +419,3 @@ /***/ (function(module, exports, __webpack_require__) {

function EventStore() {
var state = {
listeners: []
};
var listeners = [];

@@ -446,3 +425,3 @@ function add(node, type, handler) {

node.addEventListener(type, handler, options);
state.listeners.push(function () {
listeners.push(function () {
return node.removeEventListener(type, handler, options);

@@ -454,5 +433,6 @@ });

function removeAll() {
state.listeners.filter(function (remove) {
listeners.filter(function (remove) {
return remove();
});
listeners.length = 0;
return self;

@@ -498,3 +478,3 @@ }

var utils_1 = __webpack_require__(2);
var utils_1 = __webpack_require__(1);

@@ -775,3 +755,3 @@ function EmblaCarousel(sliderRoot) {

var counter_1 = __webpack_require__(4);
var counter_1 = __webpack_require__(3);

@@ -782,3 +762,3 @@ var dragHandler_1 = __webpack_require__(11);

var limit_1 = __webpack_require__(1);
var limit_1 = __webpack_require__(2);

@@ -811,3 +791,3 @@ var pxToPercent_1 = __webpack_require__(13);

var utils_1 = __webpack_require__(2);
var utils_1 = __webpack_require__(1);

@@ -829,5 +809,5 @@ var vector1d_1 = __webpack_require__(0);

var viewSize = pxToPercent.totalPercent;
var slideIndexes = Object.keys(slides).map(Number);
var slideIndexes = utils_1.arrayKeys(slides);
var slideSizes = slides.map(utils_1.rectWidth).map(pxToPercent.measure);
var groupedSizes = utils_1.groupNumbers(slideSizes, slidesToScroll);
var groupedSizes = utils_1.groupArray(slideSizes, slidesToScroll);
var snapSizes = groupedSizes.map(function (g) {

@@ -838,2 +818,3 @@ return g.reduce(function (a, s) {

});
var snapIndexes = utils_1.arrayKeys(snapSizes);
var contentSize = slideSizes.reduce(function (a, s) {

@@ -859,7 +840,7 @@ return a + s;

var contain = !loop && containScroll;
var defaultSnaps = snapSizes.map(scrollSnap.measure);
var defaultSnaps = snapIndexes.map(scrollSnap.measure);
var containedSnaps = scrollContain.snaps(defaultSnaps);
var scrollSnaps = contain ? containedSnaps : defaultSnaps; // Index
var defaultIndexes = utils_1.groupNumbers(slideIndexes, slidesToScroll);
var defaultIndexes = utils_1.groupArray(slideIndexes, slidesToScroll);
var containedIndexes = scrollContain.indexes(defaultSnaps);

@@ -884,9 +865,4 @@ var indexMin = 0;

});
var limit = scrollLimit.measure(scrollSnaps); // Direction
var limit = scrollLimit.measure(scrollSnaps); // Draw
var direction = function direction() {
return dragHandler.pointerDown() ? dragHandler.direction.get() : engine.scrollBody.direction.get();
}; // Draw
var update = function update() {

@@ -901,3 +877,4 @@ engine.scrollBody.seek(target).update();

if (loop) {
engine.scrollLooper.loop(direction());
var direction = engine.scrollBody.direction.get();
engine.scrollLooper.loop(loopVectors, direction);
engine.slideLooper.loop(slides);

@@ -917,2 +894,3 @@ }

var target = vector1d_1.Vector1D(startLocation);
var loopVectors = [location, target];
var scrollBody = scrollBody_1.ScrollBody({

@@ -968,4 +946,3 @@ location: location,

location: location,
scrollBody: scrollBody,
tolerance: 50
scrollBody: scrollBody
}),

@@ -981,4 +958,3 @@ scrollBy: scrollBy_1.ScrollBy({

location: location,
pxToPercent: pxToPercent,
vectors: [location, target]
pxToPercent: pxToPercent
}),

@@ -1063,9 +1039,7 @@ scrollProgress: scrollProgress_1.ScrollProgress({

var end = cancelAnimationFrame.bind(window);
var state = {
animationFrame: 0
};
var animationFrame = 0;
function ifAnimating(active, cb) {
return function () {
if (active === !!state.animationFrame) cb();
if (active === !!animationFrame) cb();
};

@@ -1075,8 +1049,8 @@ }

function start() {
state.animationFrame = run(callback);
animationFrame = run(callback);
}
function stop() {
end(state.animationFrame);
state.animationFrame = 0;
end(animationFrame);
animationFrame = 0;
}

@@ -1105,3 +1079,3 @@

var direction_1 = __webpack_require__(3);
var direction_1 = __webpack_require__(4);

@@ -1122,3 +1096,2 @@ var eventStore_1 = __webpack_require__(5);

limit = params.limit;
var direction = dragTracker.direction;
var focusNodes = ['INPUT', 'SELECT', 'TEXTAREA'];

@@ -1147,8 +1120,6 @@ var startX = vector1d_1.Vector1D(0);

var dragThreshold = 4;
var state = {
isDown: false,
isMouse: false,
preventClick: false,
preventScroll: false
};
var pointerIsDown = false;
var preventScroll = false;
var preventClick = false;
var isMouse = false;

@@ -1165,3 +1136,3 @@ function addActivationEvents() {

function addInteractionEvents() {
var node = !state.isMouse ? element : document;
var node = !isMouse ? element : document;
interactionEvents.add(node, 'touchmove', move).add(node, 'touchend', up).add(node, 'mousemove', move).add(node, 'mouseup', up);

@@ -1182,3 +1153,3 @@ }

var speed = dragFree ? freeSpeed : snapSpeed;
var type = state.isMouse ? 'mouse' : 'touch';
var type = isMouse ? 'mouse' : 'touch';
return speed[type];

@@ -1189,3 +1160,3 @@ }

var boost = dragFree ? freeForceBoost : snapForceBoost;
var type = state.isMouse ? 'mouse' : 'touch';
var type = isMouse ? 'mouse' : 'touch';
return boost[type];

@@ -1213,3 +1184,3 @@ }

function down(evt) {
var isMouse = evt.type === 'mousedown';
isMouse = evt.type === 'mousedown';
var diffToTarget = target.get() - location.get();

@@ -1221,4 +1192,3 @@ var isMoving = Math.abs(diffToTarget) >= 2;

if (isMouse && evt.button !== 0) return;
state.isDown = true;
state.isMouse = isMouse;
pointerIsDown = true;
dragTracker.pointerDown(evt);

@@ -1233,3 +1203,3 @@ dragStartLocation.set(target);

events.dispatch('dragStart');
if (clearPreventClick) state.preventClick = false;
if (clearPreventClick) preventClick = false;
if (preventDefault) evt.preventDefault();

@@ -1239,3 +1209,3 @@ }

function move(evt) {
if (!state.preventScroll && !state.isMouse) {
if (!preventScroll && !isMouse) {
var X = dragTracker.readPoint(evt, 'x').get();

@@ -1245,4 +1215,4 @@ var Y = dragTracker.readPoint(evt, 'y').get();

var diffY = Math.abs(Y - startY.get());
state.preventScroll = diffX > diffY;
if (!state.preventScroll && !state.preventClick) return up();
preventScroll = diffX > diffY;
if (!preventScroll && !preventClick) return up();
}

@@ -1253,5 +1223,4 @@

var resist = !params.loop && reachedLimit ? 2 : 1;
var preventClick = !state.preventClick && diff;
if (preventClick) state.preventClick = true;
target.addNumber(diff / resist);
if (!preventClick && diff) preventClick = true;
target.add(diff / resist);
evt.preventDefault();

@@ -1264,7 +1233,6 @@ }

var isMoving = Math.abs(diffToTarget) >= 0.5;
var preventClick = isMoving && !state.isMouse;
if (preventClick) state.preventClick = true;
state.isMouse = false;
state.preventScroll = false;
state.isDown = false;
if (isMoving && !isMouse) preventClick = true;
isMouse = false;
preventScroll = false;
pointerIsDown = false;
interactionEvents.removeAll();

@@ -1277,11 +1245,11 @@ scrollBody.useSpeed(movementSpeed());

function click(evt) {
if (state.preventClick) evt.preventDefault();
if (preventClick) evt.preventDefault();
}
function clickAllowed() {
return !state.preventClick;
return !preventClick;
}
function pointerDown() {
return state.isDown;
return pointerIsDown;
}

@@ -1292,3 +1260,2 @@

clickAllowed: clickAllowed,
direction: direction,
pointerDown: pointerDown,

@@ -1313,4 +1280,2 @@ removeAllEvents: removeAllEvents

var direction_1 = __webpack_require__(3);
var vector1d_1 = __webpack_require__(0);

@@ -1327,15 +1292,12 @@

var pointValue = vector1d_1.Vector1D(0);
var direction = direction_1.Direction(0);
var trackInterval = 10;
var state = {
isMouse: false,
trackPoints: [],
trackTime: new Date().getTime()
};
var trackPoints = [];
var trackTime = new Date().getTime();
var isMouse = false;
function readPoint(evt, axis) {
state.isMouse = !evt.touches;
isMouse = !evt.touches;
var c = coords[axis];
var value = state.isMouse ? evt[c] : evt.touches[0][c];
return pointValue.setNumber(value);
var value = isMouse ? evt[c] : evt.touches[0][c];
return pointValue.set(value);
}

@@ -1353,11 +1315,10 @@

var time2 = new Date().getTime();
var time1 = state.trackTime;
var time1 = trackTime;
if (time2 - time1 >= trackInterval) {
state.trackPoints.push(point.get());
state.trackTime = time2;
trackPoints.push(point.get());
trackTime = time2;
}
diffDrag.set(point).subtract(lastDrag);
direction.set(diffDrag);
lastDrag.set(point);

@@ -1369,4 +1330,4 @@ return pxToPercent.measure(diffDrag.get());

var currentPoint = lastDrag.get();
var trackLength = state.isMouse ? 5 : 4;
var point = state.trackPoints.slice(-trackLength).map(function (trackPoint) {
var trackLength = isMouse ? 5 : 4;
var point = trackPoints.slice(-trackLength).map(function (trackPoint) {
return currentPoint - trackPoint;

@@ -1376,4 +1337,4 @@ }).sort(function (p1, p2) {

})[0];
lastDrag.setNumber(point || 0);
state.trackPoints = [];
lastDrag.set(point || 0);
trackPoints = [];
return pxToPercent.measure(lastDrag.get());

@@ -1383,3 +1344,2 @@ }

var self = {
direction: direction,
pointerDown: pointerDown,

@@ -1433,5 +1393,5 @@ pointerMove: pointerMove,

var direction_1 = __webpack_require__(3);
var direction_1 = __webpack_require__(4);
var utils_1 = __webpack_require__(2);
var utils_1 = __webpack_require__(1);

@@ -1441,6 +1401,6 @@ var vector1d_1 = __webpack_require__(0);

function ScrollBody(params) {
var roundToTwoDecimals = utils_1.roundToDecimals(2);
var location = params.location,
speed = params.speed,
mass = params.mass;
var roundToTwoDecimals = utils_1.roundToDecimals(2);
var velocity = vector1d_1.Vector1D(0);

@@ -1461,11 +1421,11 @@ var acceleration = vector1d_1.Vector1D(0);

function applyForce(force) {
force.divide(state.mass);
acceleration.add(force);
function applyForce(v) {
v.divide(state.mass);
acceleration.add(v);
}
function seek(target) {
attraction.set(target).subtract(location);
var mag = attraction.magnitude();
var m = utils_1.map(mag, 0, 100, 0, state.speed);
function seek(v) {
attraction.set(v).subtract(location);
var magnitude = attraction.get();
var m = utils_1.map(magnitude, 0, 100, 0, state.speed);
direction.set(attraction);

@@ -1477,12 +1437,12 @@ attraction.normalize().multiply(m).subtract(velocity);

function settle(target) {
var diff = target.get() - location.get();
function settle(v) {
var diff = v.get() - location.get();
var diffRounded = roundToTwoDecimals(diff);
var hasSettled = !diffRounded;
if (hasSettled) location.set(target);
if (hasSettled) location.set(v);
return hasSettled;
}
function useSpeed(desired) {
state.speed = desired;
function useSpeed(n) {
state.speed = n;
return self;

@@ -1496,4 +1456,4 @@ }

function useMass(desired) {
state.mass = desired;
function useMass(n) {
state.mass = n;
return self;

@@ -1538,4 +1498,3 @@ }

scrollBody = params.scrollBody,
animation = params.animation,
tolerance = params.tolerance;
animation = params.animation;
var min = limit.min,

@@ -1545,22 +1504,21 @@ max = limit.max,

reachedMax = limit.reachedMax;
var state = {
timeout: 0
};
var tolerance = 50;
var timeout = 0;
function shouldConstrain(v) {
var constrainMin = reachedMin(location.get()) && v.get() !== min;
var constrainMax = reachedMax(location.get()) && v.get() !== max;
return constrainMin || constrainMax;
if (timeout) return false;
if (reachedMin(location.get())) return v.get() !== min;
if (reachedMax(location.get())) return v.get() !== max;
return false;
}
function constrain(v) {
if (!state.timeout && shouldConstrain(v)) {
if (!shouldConstrain(v)) return;
timeout = window.setTimeout(function () {
var constraint = limit.constrain(v.get());
state.timeout = window.setTimeout(function () {
v.setNumber(constraint);
scrollBody.useSpeed(10).useMass(3);
animation.start();
state.timeout = 0;
}, tolerance);
}
v.set(constraint);
scrollBody.useSpeed(10).useMass(3);
animation.start();
timeout = 0;
}, tolerance);
}

@@ -1628,5 +1586,5 @@

var limit_1 = __webpack_require__(1);
var limit_1 = __webpack_require__(2);
var utils_1 = __webpack_require__(2);
var utils_1 = __webpack_require__(1);

@@ -1639,3 +1597,3 @@ function ScrollContain(params) {

slidesToScroll = params.slidesToScroll;
var indexGroups = utils_1.groupNumbers(slideIndexes, slidesToScroll);
var indexGroups = utils_1.groupArray(slideIndexes, slidesToScroll);
var contentExceedsView = contentSize > viewSize;

@@ -1710,3 +1668,3 @@ var bounds = limit_1.Limit({

var limit_1 = __webpack_require__(1);
var limit_1 = __webpack_require__(2);

@@ -1747,3 +1705,3 @@ function ScrollLimit(params) {

var limit_1 = __webpack_require__(1);
var limit_1 = __webpack_require__(2);

@@ -1753,4 +1711,3 @@ function ScrollLooper(params) {

location = params.location,
vectors = params.vectors;
var limit = params.limit,
limit = params.limit,
pxToPercent = params.pxToPercent;

@@ -1768,13 +1725,13 @@ var min = limit.min + pxToPercent.measure(0.1);

function shouldLoop(direction) {
var reachedLimit = direction === -1 ? reachedMin : reachedMax;
return direction !== 0 && reachedLimit(location.get());
if (direction === 1) return reachedMax(location.get());
if (direction === -1) return reachedMin(location.get());
return false;
}
function loop(direction) {
if (shouldLoop(direction)) {
var loopDistance = contentSize * (direction * -1);
vectors.forEach(function (v) {
return v.addNumber(loopDistance);
});
}
function loop(vectors, direction) {
if (!shouldLoop(direction)) return;
var loopDistance = contentSize * (direction * -1);
vectors.forEach(function (v) {
return v.add(loopDistance);
});
}

@@ -1832,5 +1789,5 @@

var counter_1 = __webpack_require__(4);
var counter_1 = __webpack_require__(3);
var limit_1 = __webpack_require__(1);
var limit_1 = __webpack_require__(2);

@@ -1855,11 +1812,11 @@ function ScrollSnap(params) {

return snapSizes.map(function (size, index) {
var next = counter.clone().set(index + 1);
return size + alignments[index] - alignments[next.get()];
var next = counter.set(index + 1).get();
return size + alignments[index] - alignments[next];
});
}
function measure(size, index) {
function measure(index) {
var sizes = distancesBetween.slice(0, index);
return sizes.reduce(function (a, d) {
return a - d;
return sizes.reduce(function (a, s) {
return a - s;
}, alignments[0]);

@@ -2031,3 +1988,3 @@ }

animation.start();
targetDistance.addNumber(distanceDiff);
targetDistance.add(distanceDiff);
}

@@ -2073,2 +2030,4 @@

var utils_1 = __webpack_require__(1);
var vector1d_1 = __webpack_require__(0);

@@ -2081,3 +2040,3 @@

scrollSnaps = params.scrollSnaps;
var ascItems = Object.keys(slideSizes).map(Number);
var ascItems = utils_1.arrayKeys(slideSizes);
var descItems = ascItems.slice().reverse();

@@ -2129,3 +2088,3 @@ var loopPoints = startPoints().concat(endPoints());

var t = loc > point ? initial : offset;
return target.setNumber(0).setNumber(t);
return target.set(0).set(t);
};

@@ -2191,9 +2150,7 @@

var utils_1 = __webpack_require__(2);
var utils_1 = __webpack_require__(1);
var vector1d_1 = __webpack_require__(0);
function Translate(node) {
var roundToTwoDecimals = utils_1.roundToDecimals(2);
var translate = vector1d_1.Vector1D(0);
var translate = 0;

@@ -2206,8 +2163,6 @@ function translateX(n) {

var target = roundToTwoDecimals(v.get());
if (translate.get() !== target) {
getComputedStyle(node).transform;
node.style.transform = translateX(target);
translate.setNumber(target);
}
if (translate === target) return;
getComputedStyle(node).transform;
node.style.transform = translateX(target);
translate = target;
}

@@ -2235,3 +2190,3 @@

function EventDispatcher() {
var state = {
var listeners = {
destroy: [],

@@ -2248,4 +2203,3 @@ dragEnd: [],

function dispatch(evt) {
var eventListeners = state[evt];
eventListeners.forEach(function (e) {
listeners[evt].forEach(function (e) {
return e();

@@ -2257,4 +2211,3 @@ });

function on(evt, cb) {
var eventListeners = state[evt];
state[evt] = eventListeners.concat([cb]);
listeners[evt] = listeners[evt].concat([cb]);
return self;

@@ -2264,4 +2217,3 @@ }

function off(evt, cb) {
var eventListeners = state[evt];
state[evt] = eventListeners.filter(function (e) {
listeners[evt] = listeners[evt].filter(function (e) {
return e !== cb;

@@ -2268,0 +2220,0 @@ });

{
"name": "embla-carousel",
"version": "2.8.0",
"version": "2.8.1",
"author": "David Cetinkaya",

@@ -58,3 +58,3 @@ "private": false,

"jest": "^24.9.0",
"node-sass": "^4.13.0",
"node-sass": "^4.13.1",
"npm-run-all": "^4.1.5",

@@ -61,0 +61,0 @@ "postcss-cli": "^6.1.3",

@@ -65,2 +65,4 @@ <br />

<br>
## QuickStart

@@ -116,2 +118,4 @@

<br>
## Options

@@ -140,3 +144,3 @@

<details open>
<details>
<summary>

@@ -831,2 +835,4 @@ Align the slides relative to the carousel viewport.

<br>
## API

@@ -1783,2 +1789,4 @@

<br>
## Events

@@ -2074,2 +2082,4 @@

<br>
## CodeSandbox

@@ -2095,2 +2105,4 @@

<br>
## Browser Support

@@ -2097,0 +2109,0 @@

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