Commit 90f77e4060a4bd137d10c86ddfc03d29620d821d
1 parent
538b964b
updated carousel style
Showing
3 changed files
with
55 additions
and
11 deletions
Show diff stats
src/components/carousel/carousel.vue
| 1 | <template> | 1 | <template> |
| 2 | <div :class="classes"> | 2 | <div :class="classes"> |
| 3 | - <!-- button --> | 3 | + <div :class="[prefixCls + '-arrow', 'left']"> |
| 4 | + <div class='placeholder'></div> | ||
| 5 | + <Icon type="arrow-left-b"></Icon> | ||
| 6 | + </div> | ||
| 4 | <div :class="[prefixCls + '-list']"> | 7 | <div :class="[prefixCls + '-list']"> |
| 5 | <div :class="[prefixCls + '-track']" :style="trackStyles" v-el:slides> | 8 | <div :class="[prefixCls + '-track']" :style="trackStyles" v-el:slides> |
| 6 | <!-- opacity: 1; width: 4480px; transform: translate3d(-1120px, 0px, 0px); --> | 9 | <!-- opacity: 1; width: 4480px; transform: translate3d(-1120px, 0px, 0px); --> |
| 7 | <slot></slot> | 10 | <slot></slot> |
| 8 | </div> | 11 | </div> |
| 9 | </div> | 12 | </div> |
| 10 | - <!-- button --> | 13 | + <div :class="[prefixCls + '-arrow', 'right']"> |
| 14 | + <div class='placeholder'></div> | ||
| 15 | + <Icon type="arrow-right-b"></Icon> | ||
| 16 | + </div> | ||
| 17 | + <!-- dots --> | ||
| 11 | </div> | 18 | </div> |
| 12 | </template> | 19 | </template> |
| 13 | <script> | 20 | <script> |
| @@ -39,10 +46,6 @@ | @@ -39,10 +46,6 @@ | ||
| 39 | type: Boolean, | 46 | type: Boolean, |
| 40 | default: true | 47 | default: true |
| 41 | }, | 48 | }, |
| 42 | - fade: { | ||
| 43 | - type: Boolean, | ||
| 44 | - default: false | ||
| 45 | - }, | ||
| 46 | vertical: { | 49 | vertical: { |
| 47 | type: Boolean, | 50 | type: Boolean, |
| 48 | default: false | 51 | default: false |
| @@ -122,8 +125,6 @@ | @@ -122,8 +125,6 @@ | ||
| 122 | }); | 125 | }); |
| 123 | 126 | ||
| 124 | this.slides = slides; | 127 | this.slides = slides; |
| 125 | - | ||
| 126 | - // this.updateSlideWidth(); | ||
| 127 | }, | 128 | }, |
| 128 | updatePos () { | 129 | updatePos () { |
| 129 | this.findChild((child) => { | 130 | this.findChild((child) => { |
src/styles/components/carousel.less
| @@ -29,6 +29,8 @@ | @@ -29,6 +29,8 @@ | ||
| 29 | display: block; | 29 | display: block; |
| 30 | 30 | ||
| 31 | overflow: hidden; | 31 | overflow: hidden; |
| 32 | + | ||
| 33 | + z-index: 1; | ||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | &-item { | 36 | &-item { |
| @@ -37,4 +39,42 @@ | @@ -37,4 +39,42 @@ | ||
| 37 | min-height: 1px; | 39 | min-height: 1px; |
| 38 | display: block; | 40 | display: block; |
| 39 | } | 41 | } |
| 42 | + | ||
| 43 | + &-arrow { | ||
| 44 | + position: absolute; | ||
| 45 | + top: 0; | ||
| 46 | + bottom: 0; | ||
| 47 | + height: 100%; | ||
| 48 | + | ||
| 49 | + text-align: center; | ||
| 50 | + | ||
| 51 | + & > * { | ||
| 52 | + display: inline-block; | ||
| 53 | + vertical-align: middle; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + .placeholder{ | ||
| 57 | + overflow: hidden; | ||
| 58 | + width: 0; | ||
| 59 | + min-height: inherit; | ||
| 60 | + height: inherit; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + z-index: 3; | ||
| 64 | + | ||
| 65 | + &.left { | ||
| 66 | + left: 0; | ||
| 67 | + } | ||
| 68 | + &.right { | ||
| 69 | + right: 0; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + width: 10%; | ||
| 73 | + | ||
| 74 | + cursor: pointer; | ||
| 75 | + | ||
| 76 | + &:hover { | ||
| 77 | + background: fade(#000, 30%); | ||
| 78 | + } | ||
| 79 | + } | ||
| 40 | } | 80 | } |
test/routers/carousel.vue
| @@ -12,10 +12,11 @@ | @@ -12,10 +12,11 @@ | ||
| 12 | Speed <Slider :value.sync="autoplaySpeed" :min="300" :max="5000"></Slider> | 12 | Speed <Slider :value.sync="autoplaySpeed" :min="300" :max="5000"></Slider> |
| 13 | </i-col> | 13 | </i-col> |
| 14 | </Row> | 14 | </Row> |
| 15 | - <Carousel style="width: 400px" | 15 | + <Carousel style="width: 50%; border: solid 1px #000" |
| 16 | :current-index.sync="currentIndex" | 16 | :current-index.sync="currentIndex" |
| 17 | :autoplay="autoplay" | 17 | :autoplay="autoplay" |
| 18 | - :autoplay-speed="autoplaySpeed"> | 18 | + :autoplay-speed="autoplaySpeed" |
| 19 | + easing="linear"> | ||
| 19 | <Carousel-item> | 20 | <Carousel-item> |
| 20 | <Alert type="warning" show-icon> | 21 | <Alert type="warning" show-icon> |
| 21 | 警告提示文案 | 22 | 警告提示文案 |
| @@ -24,7 +25,9 @@ | @@ -24,7 +25,9 @@ | ||
| 24 | </template> | 25 | </template> |
| 25 | </Alert> | 26 | </Alert> |
| 26 | </Carousel-item> | 27 | </Carousel-item> |
| 27 | - <Carousel-item>test2</Carousel-item> | 28 | + <Carousel-item style="text-align: center"> |
| 29 | + <Icon type="checkmark" style="font-size: 5em"></Icon> | ||
| 30 | + </Carousel-item> | ||
| 28 | <Carousel-item>test3</Carousel-item> | 31 | <Carousel-item>test3</Carousel-item> |
| 29 | </Carousel> | 32 | </Carousel> |
| 30 | </template> | 33 | </template> |