vue3-carousel
Advanced tools
Comparing version 0.1.5 to 0.1.6
/** | ||
* Vue 3 Carousel 0.1.4 | ||
* Vue 3 Carousel 0.1.5 | ||
* (c) 2020 | ||
@@ -40,2 +40,18 @@ * @license MIT | ||
} | ||
/** | ||
* return a throttle version of the function | ||
* Throttling | ||
* | ||
*/ | ||
function throttle(fn, limit) { | ||
let inThrottle; | ||
return function (...args) { | ||
const self = this; | ||
if (!inThrottle) { | ||
fn.apply(self, args); | ||
inThrottle = true; | ||
setTimeout(() => (inThrottle = false), limit); | ||
} | ||
}; | ||
} | ||
@@ -146,3 +162,3 @@ var Carousel = defineComponent({ | ||
updateSlideWidth(); | ||
}, 300); | ||
}, 16); | ||
/** | ||
@@ -163,5 +179,7 @@ * Setup functions | ||
const slidesArray = [...Array(slidesCount.value).keys()]; | ||
const shifts = currentSlide.value + middleSlide.value + 1; | ||
for (let i = 0; i < shifts; i++) { | ||
slidesArray.push(Number(slidesArray.shift())); | ||
if (config.wrapAround) { | ||
const shifts = currentSlide.value + middleSlide.value + 1; | ||
for (let i = 0; i < shifts; i++) { | ||
slidesArray.push(Number(slidesArray.shift())); | ||
} | ||
} | ||
@@ -185,3 +203,3 @@ slidesBuffer.value = slidesArray; | ||
const isDragging = ref(false); | ||
const handleDrag = function (event) { | ||
const handleDrag = throttle((event) => { | ||
endPosition.x = isTouch ? event.touches[0].clientX : event.clientX; | ||
@@ -196,3 +214,3 @@ endPosition.y = isTouch ? event.touches[0].clientY : event.clientY; | ||
} | ||
}; | ||
}, 16); | ||
function handleDragStart(event) { | ||
@@ -199,0 +217,0 @@ isTouch = event.type === 'touchstart'; |
/** | ||
* Vue 3 Carousel 0.1.4 | ||
* Vue 3 Carousel 0.1.5 | ||
* (c) 2020 | ||
@@ -44,2 +44,18 @@ * @license MIT | ||
} | ||
/** | ||
* return a throttle version of the function | ||
* Throttling | ||
* | ||
*/ | ||
function throttle(fn, limit) { | ||
let inThrottle; | ||
return function (...args) { | ||
const self = this; | ||
if (!inThrottle) { | ||
fn.apply(self, args); | ||
inThrottle = true; | ||
setTimeout(() => (inThrottle = false), limit); | ||
} | ||
}; | ||
} | ||
@@ -150,3 +166,3 @@ var Carousel = vue.defineComponent({ | ||
updateSlideWidth(); | ||
}, 300); | ||
}, 16); | ||
/** | ||
@@ -167,5 +183,7 @@ * Setup functions | ||
const slidesArray = [...Array(slidesCount.value).keys()]; | ||
const shifts = currentSlide.value + middleSlide.value + 1; | ||
for (let i = 0; i < shifts; i++) { | ||
slidesArray.push(Number(slidesArray.shift())); | ||
if (config.wrapAround) { | ||
const shifts = currentSlide.value + middleSlide.value + 1; | ||
for (let i = 0; i < shifts; i++) { | ||
slidesArray.push(Number(slidesArray.shift())); | ||
} | ||
} | ||
@@ -189,3 +207,3 @@ slidesBuffer.value = slidesArray; | ||
const isDragging = vue.ref(false); | ||
const handleDrag = function (event) { | ||
const handleDrag = throttle((event) => { | ||
endPosition.x = isTouch ? event.touches[0].clientX : event.clientX; | ||
@@ -200,3 +218,3 @@ endPosition.y = isTouch ? event.touches[0].clientY : event.clientY; | ||
} | ||
}; | ||
}, 16); | ||
function handleDragStart(event) { | ||
@@ -203,0 +221,0 @@ isTouch = event.type === 'touchstart'; |
@@ -6,2 +6,8 @@ /** | ||
*/ | ||
export declare function debounce(fn: Function, delay: number): Function; | ||
export declare function debounce(fn: (...args: any[]) => unknown, delay: number): typeof fn; | ||
/** | ||
* return a throttle version of the function | ||
* Throttling | ||
* | ||
*/ | ||
export declare function throttle(fn: (...args: any[]) => unknown, limit: number): typeof fn; |
{ | ||
"name": "vue3-carousel", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "rollup -c", |
@@ -5,2 +5,6 @@ # Vue 3 Carousel | ||
## Documentation | ||
https://ismail9k.github.io/vue3-carousel/ | ||
## TODO | ||
@@ -7,0 +11,0 @@ |
@@ -9,2 +9,3 @@ { | ||
"allowSyntheticDefaultImports": true, | ||
"noImplicitThis": false, | ||
"declaration": true, | ||
@@ -11,0 +12,0 @@ "declarationDir": "./dist", |
Sorry, the diff of this file is not supported yet
42006
1078
77