From f921d5bd261068c5412ff3fc2238f88865b6ddfa Mon Sep 17 00:00:00 2001 From: chenjiajian <770230504@qq.com> Date: Fri, 7 Jul 2023 17:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0space=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/swipe/index.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/swipe/index.js b/src/swipe/index.js index 9f7ce03..768201b 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -55,7 +55,7 @@ class Swipe extends Component { }, arrow: { type: String, - default: 'hover' // hover or alway + default: 'hover' // hover or alway or none }, type: { type: String, @@ -73,6 +73,10 @@ class Swipe extends Component { pauseOnHover: { type: Boolean, default: true + }, + space: { + type: Number, + default: 0 } } @@ -145,6 +149,7 @@ class Swipe extends Component { right: 3%; } .indicator { + z-index: 10; display: flex; align-items: center; justify-content: center; @@ -323,7 +328,7 @@ class Swipe extends Component { }) let toggleBtns = - this.direction === 'horizontal' + this.arrow !== 'none' && this.direction === 'horizontal' ? html`
@@ -446,9 +451,16 @@ class SwipeItem extends Component { } calcCardTranslate(index, activeIndex) { + let space = 0 + if (this.$parent.space) { + space = 0.66 + +this.$parent.space / 100 + } const parentWidth = this.$parent.offsetWidth if (this.inStage) { - return (parentWidth * ((2 - CARD_SCALE) * (index - activeIndex) + 1)) / 4 + return ( + (parentWidth * ((2 + space - CARD_SCALE) * (index - activeIndex) + 1)) / + 4 + ) } else if (index < activeIndex) { return (-(1 + CARD_SCALE) * parentWidth) / 4 } else {