diff --git a/examples/routers/carousel.vue b/examples/routers/carousel.vue index 097d257b..a7706997 100644 --- a/examples/routers/carousel.vue +++ b/examples/routers/carousel.vue @@ -1,39 +1,79 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/carousel/carousel.vue b/src/components/carousel/carousel.vue index 542c726a..6bfd7fd6 100644 --- a/src/components/carousel/carousel.vue +++ b/src/components/carousel/carousel.vue @@ -113,10 +113,13 @@ ]; }, trackStyles () { + // #6076 + const visibleStyle = this.trackIndex === -1 ? 'hidden' : 'visible'; return { width: `${this.trackWidth}px`, transform: `translate3d(${-this.trackOffset}px, 0px, 0px)`, - transition: `transform 500ms ${this.easing}` + transition: `transform 500ms ${this.easing}`, + visibility : visibleStyle }; }, copyTrackStyles () { @@ -125,7 +128,7 @@ transform: `translate3d(${-this.trackCopyOffset}px, 0px, 0px)`, transition: `transform 500ms ${this.easing}`, position: 'absolute', - top: 0 + //top: 0 }; }, arrowClasses () { @@ -198,8 +201,8 @@ child.width = this.listWidth; child.height = typeof this.height === 'number' ? `${this.height}px` : this.height; }); - - this.trackWidth = (this.slides.length || 0) * this.listWidth; + const slidesLength = this.slides.length || 0 + this.trackWidth = slidesLength * this.listWidth; }, // use when slot changed slotChange () { diff --git a/src/styles/components/carousel.less b/src/styles/components/carousel.less index e8c69acf..736e11a0 100644 --- a/src/styles/components/carousel.less +++ b/src/styles/components/carousel.less @@ -24,15 +24,14 @@ &-track { position: relative; - top: 0; + top: 100%; left: 0; display: block; - overflow: hidden; - z-index: 1; &.higher { z-index: 2; + top: 0; } }