Przeglądaj źródła

Carousel: apply infinite sliding in non-card mode (#2622)

杨奕 8 lat temu
rodzic
commit
7628fc0e41

+ 3 - 4
packages/carousel/src/item.vue

@@ -70,11 +70,10 @@
       translateItem(index, activeIndex) {
         const parentWidth = this.$parent.$el.offsetWidth;
         const length = this.$parent.items.length;
-
+        if (index !== activeIndex && length > 2) {
+          index = this.processIndex(index, activeIndex, length);
+        }
         if (this.$parent.type === 'card') {
-          if (index !== activeIndex && length > 2) {
-            index = this.processIndex(index, activeIndex, length);
-          }
           this.inStage = Math.round(Math.abs(index - activeIndex)) <= 1;
           this.active = index === activeIndex;
           this.translate = this.calculateTranslate(index, activeIndex, parentWidth);

+ 4 - 1
packages/theme-default/src/carousel-item.css

@@ -13,10 +13,13 @@
       display: inline-block;
       transition: .4s ease-in-out;
       overflow: hidden;
+      z-index: calc(var(--index-normal) - 1);
+      @when active {
+        z-index: calc(var(--index-normal) + 1);
+      }
 
       @modifier card {
         width: 50%;
-        z-index: calc(var(--index-normal) - 1);
         &.is-in-stage {
           cursor: pointer;
           z-index: var(--index-normal);

+ 1 - 0
packages/theme-default/src/carousel.css

@@ -55,6 +55,7 @@
       transform: translateX(-50%);
       margin: 0;
       padding: 0;
+      z-index: calc(var(--index-normal) + 1);
 
       @modifier outside {
         bottom: calc(var(--carousel-indicator-height) + var(--carousel-indicator-padding-vertical) * 2);