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

embla-carousel-svelte

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embla-carousel-svelte - npm Package Compare versions

Comparing version 8.0.0-rc07 to 8.0.0-rc08

93

embla-carousel-svelte.umd.js

@@ -328,6 +328,8 @@ (function (global, factory) {

const diff = dragTracker.pointerMove(evt);
const directionDiff = direction.apply(diff);
if (diffScroll > dragThreshold) preventClick = true;
scrollBody.useFriction(0.3).useDuration(1);
if (directionDiff) scrollBody.useDirection(directionDiff);
animation.start();
target.add(direction.apply(diff));
target.add(directionDiff);
evt.preventDefault();

@@ -467,7 +469,7 @@ }

let scrollDirection = 0;
let duration = baseDuration;
let friction = baseFriction;
let scrollDuration = baseDuration;
let scrollFriction = baseFriction;
function seek() {
const diff = target.get() - location.get();
const isInstant = !friction || !duration;
const isInstant = !scrollDuration;
if (isInstant) {

@@ -477,7 +479,6 @@ bodyVelocity = 0;

} else {
bodyVelocity += diff / duration;
bodyVelocity *= friction;
bodyVelocity += diff / scrollDuration;
bodyVelocity *= scrollFriction;
location.add(bodyVelocity);
}
scrollDirection = mathSign(bodyVelocity || diff);
hasSettled = mathAbs(diff) < 0.001;

@@ -487,7 +488,6 @@ return self;

function settled() {
if (hasSettled) location.set(target);
return hasSettled;
}
function velocity() {
return bodyVelocity;
function duration() {
return scrollDuration;
}

@@ -504,11 +504,16 @@ function direction() {

function useDuration(n) {
duration = n;
scrollDuration = n;
return self;
}
function useFriction(n) {
friction = n;
scrollFriction = n;
return self;
}
function useDirection(n) {
scrollDirection = mathSign(n);
return self;
}
const self = {
direction,
duration,
seek,

@@ -518,5 +523,5 @@ settled,

useBaseDuration,
useDirection,
useFriction,
useDuration,
velocity
useDuration
};

@@ -728,10 +733,9 @@ return self;

}
function ScrollTo(animation, indexCurrent, indexPrevious, scrollTarget, targetVector, eventHandler) {
function ScrollTo(animation, indexCurrent, indexPrevious, scrollTarget, scrollBody, targetVector, eventHandler) {
function scrollTo(target) {
const distanceDiff = target.distance;
const indexDiff = target.index !== indexCurrent.get();
if (distanceDiff) {
animation.start();
targetVector.add(distanceDiff);
}
scrollBody.useDirection(distanceDiff);
targetVector.add(distanceDiff);
if (distanceDiff) animation.start();
if (indexDiff) {

@@ -812,3 +816,3 @@ indexPrevious.set(indexCurrent.get());

}
function SlideLooper(axis, direction, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, scroll, slides) {
function SlideLooper(axis, direction, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, location, slides) {
const ascItems = arrayKeys(slideSizesWithGaps);

@@ -836,11 +840,8 @@ const descItems = arrayKeys(slideSizesWithGaps).reverse();

const bounds = slideBounds.filter(b => b.index === index)[0];
const point = bounds[isStartEdge ? 'end' : 'start'];
const location = Vector1D(-1);
const translate = Translate(axis, direction, slides[index]);
const target = () => scroll.get() > point ? initial : altered;
const loopPoint = bounds[isStartEdge ? 'end' : 'start'];
return {
index,
location,
translate,
target
slideLocation: Vector1D(-1),
translate: Translate(axis, direction, slides[index]),
target: () => location.get() > loopPoint ? initial : altered
};

@@ -872,8 +873,8 @@ });

translate,
location
slideLocation
} = loopPoint;
const shift = target();
if (shift === location.get()) return;
translate.to(shift);
location.set(shift);
const shiftLocation = target();
if (shiftLocation === slideLocation.get()) return;
translate.to(shiftLocation);
slideLocation.set(shiftLocation);
});

@@ -1082,5 +1083,6 @@ }

scrollLooper,
slideLooper,
eventHandler,
animation,
slideLooper,
translate,
options: {

@@ -1097,5 +1099,3 @@ loop

}
if (!hasSettled) {
eventHandler.emit('scroll');
}
if (!hasSettled) eventHandler.emit('scroll');
if (loop) {

@@ -1105,17 +1105,8 @@ scrollLooper.loop(scrollBody.direction());

}
translate.to(location.get());
};
const render = ({
scrollBody,
translate,
location
}, lagOffset) => {
const velocity = scrollBody.velocity();
const offsetLocation = location.get() - velocity + velocity * lagOffset;
translate.to(offsetLocation);
};
const animation = {
update: () => update(engine),
render: lagOffset => render(engine, lagOffset),
start: () => animations.start(engine),
stop: () => animations.stop(engine)
stop: () => animations.stop(engine),
update: () => update(engine)
};

@@ -1129,3 +1120,3 @@ // Shared

const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
const scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, eventHandler);
const scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, scrollBody, target, eventHandler);
const slidesInView = SlidesInView(viewSize, contentSize, slideSizes, snaps, limit, loop, inViewThreshold);

@@ -1185,6 +1176,2 @@ // Engine

}
const lagOffset = mathAbs(lag / timeStep);
engines.forEach(({
animation
}) => animation.render(lagOffset));
if (animationFrame) ownerWindow.requestAnimationFrame(animate);

@@ -1191,0 +1178,0 @@ }

{
"name": "embla-carousel-svelte",
"version": "8.0.0-rc07",
"version": "8.0.0-rc08",
"author": "David Jerleke",

@@ -59,4 +59,4 @@ "description": "A lightweight carousel library with fluid motion and great swipe precision",

"dependencies": {
"embla-carousel": "8.0.0-rc07",
"embla-carousel-reactive-utils": "8.0.0-rc07"
"embla-carousel": "8.0.0-rc08",
"embla-carousel-reactive-utils": "8.0.0-rc08"
},

@@ -63,0 +63,0 @@ "peerDependencies": {

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