增加space属性

master
chenjiajian 2023-07-07 17:01:59 +08:00
parent 1e70f5302f
commit f921d5bd26
1 changed files with 15 additions and 3 deletions

View File

@ -55,7 +55,7 @@ class Swipe extends Component {
}, },
arrow: { arrow: {
type: String, type: String,
default: 'hover' // hover or alway default: 'hover' // hover or alway or none
}, },
type: { type: {
type: String, type: String,
@ -73,6 +73,10 @@ class Swipe extends Component {
pauseOnHover: { pauseOnHover: {
type: Boolean, type: Boolean,
default: true default: true
},
space: {
type: Number,
default: 0
} }
} }
@ -145,6 +149,7 @@ class Swipe extends Component {
right: 3%; right: 3%;
} }
.indicator { .indicator {
z-index: 10;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -323,7 +328,7 @@ class Swipe extends Component {
}) })
let toggleBtns = let toggleBtns =
this.direction === 'horizontal' this.arrow !== 'none' && this.direction === 'horizontal'
? html` ? html`
<div class="left toggle-btn" style=${styles} @click=${this.prev}> <div class="left toggle-btn" style=${styles} @click=${this.prev}>
<wc-icon name="left"></wc-icon> <wc-icon name="left"></wc-icon>
@ -446,9 +451,16 @@ class SwipeItem extends Component {
} }
calcCardTranslate(index, activeIndex) { calcCardTranslate(index, activeIndex) {
let space = 0
if (this.$parent.space) {
space = 0.66 + +this.$parent.space / 100
}
const parentWidth = this.$parent.offsetWidth const parentWidth = this.$parent.offsetWidth
if (this.inStage) { 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) { } else if (index < activeIndex) {
return (-(1 + CARD_SCALE) * parentWidth) / 4 return (-(1 + CARD_SCALE) * parentWidth) / 4
} else { } else {