vue3-carousel
Advanced tools
Comparing version 0.1.21 to 0.1.22
/** | ||
* Vue 3 Carousel 0.1.21 | ||
* Vue 3 Carousel 0.1.22 | ||
* (c) 2021 | ||
* @license MIT | ||
*/ | ||
import { defineComponent, ref, reactive, provide, onMounted, computed, watchEffect, h, inject } from 'vue'; | ||
import { defineComponent, ref, reactive, watch, provide, onMounted, computed, watchEffect, h, inject } from 'vue'; | ||
@@ -122,10 +122,16 @@ function counterFactory() { | ||
const slidesCounter = counterFactory(); | ||
// current config | ||
const config = reactive({}); | ||
// generate carousel configs | ||
const defaultConfig = Object.assign(Object.assign(Object.assign({}, props), props.settings), { currentSlide: props.modelValue }); | ||
const breakpoints = ref(Object.assign({}, defaultConfig.breakpoints)); | ||
// remove extra values | ||
delete defaultConfig.settings; | ||
delete defaultConfig.breakpoints; | ||
// current config | ||
const config = reactive(Object.assign({}, defaultConfig)); | ||
let defaultConfig = {}; | ||
let breakpoints = ref({}); | ||
initDefaultConfigs(); | ||
updateConfig(); | ||
// Update the carousel on props change | ||
watch(props, () => { | ||
initDefaultConfigs(); | ||
updateConfig(); | ||
updateSlidesData(); | ||
updateSlideWidth(); | ||
}); | ||
// slides | ||
@@ -142,4 +148,12 @@ const currentSlide = ref((_a = config.currentSlide) !== null && _a !== void 0 ? _a : 0); | ||
/** | ||
* Breakpoints | ||
* Configs | ||
*/ | ||
function initDefaultConfigs() { | ||
// generate carousel configs | ||
defaultConfig = Object.assign(Object.assign(Object.assign({}, props), props.settings), { currentSlide: props.modelValue }); | ||
// Set breakpoints | ||
breakpoints = ref(Object.assign({}, defaultConfig.breakpoints)); | ||
// remove extra values | ||
defaultConfig = Object.assign(Object.assign({}, defaultConfig), { settings: undefined, breakpoints: undefined }); | ||
} | ||
function updateConfig() { | ||
@@ -185,3 +199,3 @@ const breakpointsArray = Object.keys(breakpoints.value) | ||
function updateSlidesData() { | ||
paginationCount.value = (slides.value.length - config.itemsToShow) + 1; | ||
paginationCount.value = slides.value.length - config.itemsToShow + 1; | ||
slidesCount.value = slides.value.length; | ||
@@ -188,0 +202,0 @@ middleSlide.value = Math.ceil((slidesCount.value - 1) / 2); |
/** | ||
* Vue 3 Carousel 0.1.21 | ||
* Vue 3 Carousel 0.1.22 | ||
* (c) 2021 | ||
@@ -126,10 +126,16 @@ * @license MIT | ||
const slidesCounter = counterFactory(); | ||
// current config | ||
const config = vue.reactive({}); | ||
// generate carousel configs | ||
const defaultConfig = Object.assign(Object.assign(Object.assign({}, props), props.settings), { currentSlide: props.modelValue }); | ||
const breakpoints = vue.ref(Object.assign({}, defaultConfig.breakpoints)); | ||
// remove extra values | ||
delete defaultConfig.settings; | ||
delete defaultConfig.breakpoints; | ||
// current config | ||
const config = vue.reactive(Object.assign({}, defaultConfig)); | ||
let defaultConfig = {}; | ||
let breakpoints = vue.ref({}); | ||
initDefaultConfigs(); | ||
updateConfig(); | ||
// Update the carousel on props change | ||
vue.watch(props, () => { | ||
initDefaultConfigs(); | ||
updateConfig(); | ||
updateSlidesData(); | ||
updateSlideWidth(); | ||
}); | ||
// slides | ||
@@ -146,4 +152,12 @@ const currentSlide = vue.ref((_a = config.currentSlide) !== null && _a !== void 0 ? _a : 0); | ||
/** | ||
* Breakpoints | ||
* Configs | ||
*/ | ||
function initDefaultConfigs() { | ||
// generate carousel configs | ||
defaultConfig = Object.assign(Object.assign(Object.assign({}, props), props.settings), { currentSlide: props.modelValue }); | ||
// Set breakpoints | ||
breakpoints = vue.ref(Object.assign({}, defaultConfig.breakpoints)); | ||
// remove extra values | ||
defaultConfig = Object.assign(Object.assign({}, defaultConfig), { settings: undefined, breakpoints: undefined }); | ||
} | ||
function updateConfig() { | ||
@@ -189,3 +203,3 @@ const breakpointsArray = Object.keys(breakpoints.value) | ||
function updateSlidesData() { | ||
paginationCount.value = (slides.value.length - config.itemsToShow) + 1; | ||
paginationCount.value = slides.value.length - config.itemsToShow + 1; | ||
slidesCount.value = slides.value.length; | ||
@@ -192,0 +206,0 @@ middleSlide.value = Math.ceil((slidesCount.value - 1) / 2); |
{ | ||
"name": "vue3-carousel", | ||
"version": "0.1.21", | ||
"version": "0.1.22", | ||
"scripts": { | ||
@@ -19,3 +19,3 @@ "build": "rollup -c", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.44.0", | ||
"rollup": "^2.52.1", | ||
"rollup-plugin-css-only": "^3.1.0", | ||
@@ -22,0 +22,0 @@ "rollup-plugin-typescript2": "^0.30.0", |
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
47501
1218