Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | 68x 92x 154x 154x 152x 152x 153x 153x 152x 152x 152x 4x 4x 4x 152x 7x 7x 153x 154x 306x 306x 201x 4x 306x 215x 5x 5x 5x 5x 5x 5x | <template>
<div class="carousel-3d-slide" :style="slideStyle" :class="computedClasses" @click="goTo()">
<slot :index="index" :isCurrent="isCurrent" :leftIndex="leftIndex" :rightIndex="rightIndex"/>
</div>
</template>
<script>
export default {
name: 'slide',
props: {
index: {
type: Number
}
},
data () {
return {
parent: this.$parent,
styles: {},
zIndex: 999
}
},
computed: {
isCurrent () {
return this.index === this.parent.currentIndex
},
leftIndex () {
if (this.parent.oneDirectional && this.getSideIndex(this.parent.leftIndices) > this.parent.currentIndex - 1) return -1;
return this.getSideIndex(this.parent.leftIndices)
},
rightIndex () {
if (this.parent.oneDirectional && this.getSideIndex(this.parent.rightIndices) > this.parent.total - this.parent.currentIndex - 2) return -1;
return this.getSideIndex(this.parent.rightIndices)
},
slideStyle () {
let styles = {}
if (!this.isCurrent) {
const lIndex = this.leftIndex
const rIndex = this.rightIndex
if (rIndex >= 0 || lIndex >= 0) {
styles = rIndex >= 0 ? this.calculatePosition(rIndex, true, this.zIndex) : this.calculatePosition(lIndex, false, this.zIndex)
styles.opacity = 1
styles.visibility = 'visible'
}
if (this.parent.hasHiddenSlides) {
I if (this.matchIndex(this.parent.leftOutIndex)) {
styles = this.calculatePosition(this.parent.leftIndices.length - 1, false, this.zIndex)
I } else if (this.matchIndex(this.parent.rightOutIndex)) {
styles = this.calculatePosition(this.parent.rightIndices.length - 1, true, this.zIndex)
}
}
}
return Object.assign(styles, {
'border-width': this.parent.border + 'px',
'width': this.parent.slideWidth + 'px',
'height': this.parent.slideHeight + 'px',
'transition': ' transform ' + this.parent.animationSpeed + 'ms, ' +
' opacity ' + this.parent.animationSpeed + 'ms, ' +
' visibility ' + this.parent.animationSpeed + 'ms'
})
},
computedClasses () {
return {
[`left-${this.leftIndex + 1}`]: this.leftIndex >= 0,
[`right-${this.rightIndex + 1}`]: this.rightIndex >= 0,
'current': this.isCurrent
}
}
},
methods: {
getSideIndex (array) {
let index = -1
array.forEach((pos, i) => {
if (this.matchIndex(pos)) {
index = i
}
})
return index
},
matchIndex (index) {
return (index >= 0) ? this.index === index : (this.parent.total + index) === this.index
},
calculatePosition (i, positive, zIndex) {
const z = !this.parent.disable3d ? parseInt(this.parent.inverseScaling) + ((i + 1) * 100) : 0
const y = !this.parent.disable3d ? parseInt(this.parent.perspective) : 0
const leftRemain = (this.parent.space === 'auto')
? parseInt((i + 1) * (this.parent.width / 1.5), 10)
: parseInt((i + 1) * (this.parent.space), 10)
const transform = (positive)
? 'translateX(' + (leftRemain) + 'px) translateZ(-' + z + 'px) ' +
'rotateY(-' + y + 'deg)'
: 'translateX(-' + (leftRemain) + 'px) translateZ(-' + z + 'px) ' +
'rotateY(' + y + 'deg)'
const top = this.parent.space === 'auto' ? 0 : parseInt((i + 1) * (this.parent.space))
return {
transform: transform,
top: top,
zIndex: zIndex - (Math.abs(i) + 1)
}
},
goTo () {
if (!this.isCurrent) {
if (this.parent.clickable === true) {
this.parent.goFar(this.index)
}
} else {
const {index} = this;
this.parent.onMainSlideClick({index});
}
}
}
}
</script>
<style>
.carousel-3d-slide {
position: absolute;
opacity: 0;
visibility: hidden;
overflow: hidden;
top: 0;
border-radius: 1px;
border-color: #000;
border-color: rgba(0, 0, 0, 0.4);
border-style: solid;
background-size: cover;
background-color: #ccc;
display: block;
margin: 0;
box-sizing: border-box;
}
.carousel-3d-slide {
text-align: left;
}
.carousel-3d-slide img {
width: 100%;
}
.carousel-3d-slide.current {
opacity: 1 !important;
visibility: visible !important;
transform: none !important;
z-index: 999;
}
</style>
|