This commit is contained in:
mo.duan 2019-09-19 15:49:20 +08:00
parent e8f22ea094
commit 68ff748436
3 changed files with 73 additions and 31 deletions

View file

@ -1,39 +1,79 @@
<style>
.demo-carousel{
height: 200px;
line-height: 200px;
text-align: center;
color: #fff;
font-size: 20px;
background: #506b9e;
}
</style>
<template> <template>
<div style="width: 400px;"> <div>
<Carousel v-model="value1" loop arrow="always" @on-change="handleChange" @on-click="handlerClick"> <!--#6076-->
<CarouselItem v-for="it in 4" :key="it"> <Carousel loop>
<div class="demo-carousel"> <CarouselItem>
{{it}} <div class="demo-carousel">111111111111</div>
</div> </CarouselItem>
<CarouselItem>
<div class="demo-carousel">2</div>
</CarouselItem>
<CarouselItem>
<div class="demo-carousel">3</div>
</CarouselItem>
<CarouselItem>
<div class="demo-carousel">4</div>
</CarouselItem> </CarouselItem>
</Carousel> </Carousel>
<Button @click="value1 = 2">change</Button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
value1: 0
} }
}, },
methods: { methods: {
handleChange (old, newval) {
console.log(old, newval,'---on-change');
}, },
handlerClick(index){ mounted () {
console.log(index,'------on-click');
} }
},
} }
</script> </script>
<style>
.demo-carousel{
height: 100px;
}
</style>
<!--<style>-->
<!-- .demo-carousel{-->
<!-- height: 200px;-->
<!-- line-height: 200px;-->
<!-- text-align: center;-->
<!-- font-size: 20px;-->
<!-- }-->
<!--</style>-->
<!--<template>-->
<!-- <div>-->
<!-- <Carousel v-model="value1" loop @on-change="handleChange" @on-click="handlerClick">-->
<!-- <CarouselItem v-for="it in 4" :key="it">-->
<!-- <div class="demo-carousel">-->
<!-- {{it}}<Button @click="handlerIndexClick(it)">点击事件</Button>-->
<!-- </div>-->
<!-- </CarouselItem>-->
<!-- </Carousel>-->
<!-- <Button @click="value1 = 2">change</Button>-->
<!-- </div>-->
<!--</template>-->
<!--<script>-->
<!-- export default {-->
<!-- data () {-->
<!-- return {-->
<!-- value1: 0-->
<!-- }-->
<!-- },-->
<!-- methods: {-->
<!-- handleChange (old, newval) {-->
<!-- console.log(old, newval,'-&#45;&#45;on-change');-->
<!-- },-->
<!-- handlerClick(index){-->
<!-- console.log(index,'&#45;&#45;&#45;&#45;&#45;&#45;on-click');-->
<!-- },-->
<!-- handlerIndexClick(it){-->
<!-- console.log(it,'&#45;&#45;&#45;&#45;&#45;&#45;it')-->
<!-- }-->
<!-- },-->
<!-- }-->
<!--</script>-->

View file

@ -113,10 +113,13 @@
]; ];
}, },
trackStyles () { trackStyles () {
// #6076
const visibleStyle = this.trackIndex === -1 ? 'hidden' : 'visible';
return { return {
width: `${this.trackWidth}px`, width: `${this.trackWidth}px`,
transform: `translate3d(${-this.trackOffset}px, 0px, 0px)`, transform: `translate3d(${-this.trackOffset}px, 0px, 0px)`,
transition: `transform 500ms ${this.easing}` transition: `transform 500ms ${this.easing}`,
visibility : visibleStyle
}; };
}, },
copyTrackStyles () { copyTrackStyles () {
@ -125,7 +128,7 @@
transform: `translate3d(${-this.trackCopyOffset}px, 0px, 0px)`, transform: `translate3d(${-this.trackCopyOffset}px, 0px, 0px)`,
transition: `transform 500ms ${this.easing}`, transition: `transform 500ms ${this.easing}`,
position: 'absolute', position: 'absolute',
top: 0 //top: 0
}; };
}, },
arrowClasses () { arrowClasses () {
@ -198,8 +201,8 @@
child.width = this.listWidth; child.width = this.listWidth;
child.height = typeof this.height === 'number' ? `${this.height}px` : this.height; child.height = typeof this.height === 'number' ? `${this.height}px` : this.height;
}); });
const slidesLength = this.slides.length || 0
this.trackWidth = (this.slides.length || 0) * this.listWidth; this.trackWidth = slidesLength * this.listWidth;
}, },
// use when slot changed // use when slot changed
slotChange () { slotChange () {

View file

@ -24,15 +24,14 @@
&-track { &-track {
position: relative; position: relative;
top: 0; top: 100%;
left: 0; left: 0;
display: block; display: block;
overflow: hidden; overflow: hidden;
z-index: 1; z-index: 1;
&.higher { &.higher {
z-index: 2; z-index: 2;
top: 0;
} }
} }