vue3-carousel
Advanced tools
Comparing version 0.1.9 to 0.1.10
/** | ||
* Vue 3 Carousel 0.1.9 | ||
* Vue 3 Carousel 0.1.10 | ||
* (c) 2021 | ||
@@ -8,16 +8,18 @@ * @license MIT | ||
var slidesCounter = new Proxy({ value: 0, read: 0 }, { | ||
get(obj, prop) { | ||
if (!(prop in obj)) | ||
return 0; | ||
if (prop === 'read') { | ||
return obj[prop]; | ||
} | ||
return obj[prop]++; | ||
}, | ||
set(obj, prop, value) { | ||
obj[prop] = Math.max(value, 0); | ||
return true; | ||
}, | ||
}); | ||
function counterFactory() { | ||
return new Proxy({ value: 0, read: 0 }, { | ||
get(obj, prop) { | ||
if (!(prop in obj)) | ||
return 0; | ||
if (prop === 'read') { | ||
return obj[prop]; | ||
} | ||
return obj[prop]++; | ||
}, | ||
set(obj, prop, value) { | ||
obj[prop] = Math.max(value, 0); | ||
return true; | ||
}, | ||
}); | ||
} | ||
@@ -108,2 +110,3 @@ /** | ||
const slidesCount = ref(1); | ||
const slidesCounter = counterFactory(); | ||
// generate carousel configs | ||
@@ -125,2 +128,3 @@ const defaultConfig = Object.assign(Object.assign({}, props), props.settings); | ||
provide('currentSlide', currentSlide); | ||
provide('slidesCounter', slidesCounter); | ||
const { default: slotDefault, slides: slotSlides, addons: slotAddons } = slots; | ||
@@ -228,3 +232,4 @@ const slidesElements = (slotSlides === null || slotSlides === void 0 ? void 0 : slotSlides()) || (slotDefault === null || slotDefault === void 0 ? void 0 : slotDefault()) || []; | ||
isDragging.value = false; | ||
const draggedSlides = Math.round(dragged.x / slideWidth.value); | ||
const tolerance = Math.sign(dragged.x) * 0.4; | ||
const draggedSlides = Math.round(dragged.x / slideWidth.value + tolerance); | ||
slideTo(currentSlide.value - draggedSlides); | ||
@@ -372,2 +377,3 @@ dragged.x = 0; | ||
const slidesBuffer = inject('slidesBuffer', ref([])); | ||
const slidesCounter = inject('slidesCounter'); | ||
const slideOrder = slidesCounter.value; | ||
@@ -374,0 +380,0 @@ const wrapOrder = ref(slideOrder); |
/** | ||
* Vue 3 Carousel 0.1.9 | ||
* Vue 3 Carousel 0.1.10 | ||
* (c) 2021 | ||
@@ -12,16 +12,18 @@ * @license MIT | ||
var slidesCounter = new Proxy({ value: 0, read: 0 }, { | ||
get(obj, prop) { | ||
if (!(prop in obj)) | ||
return 0; | ||
if (prop === 'read') { | ||
return obj[prop]; | ||
} | ||
return obj[prop]++; | ||
}, | ||
set(obj, prop, value) { | ||
obj[prop] = Math.max(value, 0); | ||
return true; | ||
}, | ||
}); | ||
function counterFactory() { | ||
return new Proxy({ value: 0, read: 0 }, { | ||
get(obj, prop) { | ||
if (!(prop in obj)) | ||
return 0; | ||
if (prop === 'read') { | ||
return obj[prop]; | ||
} | ||
return obj[prop]++; | ||
}, | ||
set(obj, prop, value) { | ||
obj[prop] = Math.max(value, 0); | ||
return true; | ||
}, | ||
}); | ||
} | ||
@@ -112,2 +114,3 @@ /** | ||
const slidesCount = vue.ref(1); | ||
const slidesCounter = counterFactory(); | ||
// generate carousel configs | ||
@@ -129,2 +132,3 @@ const defaultConfig = Object.assign(Object.assign({}, props), props.settings); | ||
vue.provide('currentSlide', currentSlide); | ||
vue.provide('slidesCounter', slidesCounter); | ||
const { default: slotDefault, slides: slotSlides, addons: slotAddons } = slots; | ||
@@ -232,3 +236,4 @@ const slidesElements = (slotSlides === null || slotSlides === void 0 ? void 0 : slotSlides()) || (slotDefault === null || slotDefault === void 0 ? void 0 : slotDefault()) || []; | ||
isDragging.value = false; | ||
const draggedSlides = Math.round(dragged.x / slideWidth.value); | ||
const tolerance = Math.sign(dragged.x) * 0.4; | ||
const draggedSlides = Math.round(dragged.x / slideWidth.value + tolerance); | ||
slideTo(currentSlide.value - draggedSlides); | ||
@@ -376,2 +381,3 @@ dragged.x = 0; | ||
const slidesBuffer = vue.inject('slidesBuffer', vue.ref([])); | ||
const slidesCounter = vue.inject('slidesCounter'); | ||
const slideOrder = slidesCounter.value; | ||
@@ -378,0 +384,0 @@ const wrapOrder = vue.ref(slideOrder); |
@@ -1,6 +0,6 @@ | ||
interface Counter { | ||
export interface Counter { | ||
value: number; | ||
[name: string]: any; | ||
} | ||
declare const _default: Counter; | ||
export default _default; | ||
declare function counterFactory(): Counter; | ||
export default counterFactory; |
{ | ||
"name": "vue3-carousel", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "rollup -c", |
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
43876
1098