From e97f0eb05b33d97b6972e0d3ea5e41fda9ecabb8 Mon Sep 17 00:00:00 2001 From: Rodrigo Sanchez Date: Mon, 18 Mar 2024 14:28:01 +1100 Subject: [PATCH] added carousel changes --- api-generator/components/carousel.js | 6 +- components/lib/carousel/Carousel.vue | 162 ++++++++++++++------------- 2 files changed, 92 insertions(+), 76 deletions(-) diff --git a/api-generator/components/carousel.js b/api-generator/components/carousel.js index 7cb397595..18024cec2 100644 --- a/api-generator/components/carousel.js +++ b/api-generator/components/carousel.js @@ -121,7 +121,11 @@ const CarouselSlots = [ { name: 'nexticon', description: 'Custom next icon template.' - } + }, + { + name: 'empty', + description: 'Custom content when there is no data to display.' + }, ]; module.exports = { diff --git a/components/lib/carousel/Carousel.vue b/components/lib/carousel/Carousel.vue index 4a0019af4..8e09c7be0 100755 --- a/components/lib/carousel/Carousel.vue +++ b/components/lib/carousel/Carousel.vue @@ -4,90 +4,94 @@
-
- + +
+
@@ -231,7 +235,9 @@ export default { this.d_oldNumVisible = this.d_numVisible; this.d_oldValue = this.value; - this.$refs.itemsContainer.style.transform = this.isVertical() ? `translate3d(0, ${totalShiftedItems * (100 / this.d_numVisible)}%, 0)` : `translate3d(${totalShiftedItems * (100 / this.d_numVisible)}%, 0, 0)`; + if(!this.empty) { + this.$refs.itemsContainer.style.transform = this.isVertical() ? `translate3d(0, ${totalShiftedItems * (100 / this.d_numVisible)}%, 0)` : `translate3d(${totalShiftedItems * (100 / this.d_numVisible)}%, 0, 0)`; + } } if (isCircular) { @@ -604,6 +610,12 @@ export default { } }, computed: { + empty() { + return !this.value || this.value.length === 0; + }, + emptyMessageText() { + return this.$primevue.config?.locale?.emptyMessage || ''; + }, totalIndicators() { return this.value ? Math.max(Math.ceil((this.value.length - this.d_numVisible) / this.d_numScroll) + 1, 0) : 0; },