Authored by 陈峰

commit

  1 +<template>
  2 + <transition name="action-sheet-fade">
  3 + <Popup
  4 + class="yoho-action-sheet"
  5 + type="yoho-action-sheet"
  6 + :center="false"
  7 + :mask="true"
  8 + :z-index="zIndex"
  9 + v-show="isVisible"
  10 + @mask-click="maskClick"
  11 + >
  12 + <transition name="action-sheet-move">
  13 + <div class="detail" v-show="isVisible">
  14 + <slot></slot>
  15 + </div>
  16 + </transition>
  17 + </Popup>
  18 + </transition>
  19 +</template>
  20 +
  21 +<script>
  22 +import {Popup} from 'cube-ui';
  23 +
  24 +export default {
  25 + name: 'YohoActionSheet',
  26 + props: {
  27 + maskClosable: {
  28 + type: Boolean,
  29 + default: true
  30 + },
  31 + zIndex: {
  32 + type: Number,
  33 + default: 100
  34 + },
  35 + visible: {
  36 + type: Boolean,
  37 + default: false
  38 + }
  39 + },
  40 + data() {
  41 + return {
  42 + isVisible: false,
  43 + };
  44 + },
  45 + mounted() {
  46 + this.$watch('visible', (newVal) => {
  47 + if (newVal) {
  48 + this.show();
  49 + } else {
  50 + this.hide();
  51 + }
  52 + }, {
  53 + immediate: true
  54 + });
  55 + },
  56 + components: {
  57 + Popup
  58 + },
  59 + methods: {
  60 + maskClick() {
  61 + this.maskClosable && this.cancel();
  62 + },
  63 +
  64 + cancel() {
  65 + this.hide();
  66 + this.$emit('cancel');
  67 + },
  68 +
  69 + show() {
  70 + this.isVisible = true;
  71 + },
  72 +
  73 + hide() {
  74 + this.isVisible = false;
  75 + }
  76 + }
  77 +};
  78 +
  79 +</script>
  80 +
  81 +<style lang="scss" scoped>
  82 +.action-sheet-fade-enter,
  83 +.action-sheet-fade-leave-active {
  84 + opacity: 0;
  85 +}
  86 +
  87 +.action-sheet-fade-enter-active,
  88 +.action-sheet-fade-leave-active {
  89 + transition: all 0.3s ease-in-out;
  90 +}
  91 +
  92 +.action-sheet-move-enter,
  93 +.action-sheet-move-leave-active {
  94 + transform: translate3d(0, 100%, 0);
  95 +}
  96 +
  97 +.action-sheet-move-enter-active,
  98 +.action-sheet-move-leave-active {
  99 + transition: all 0.3s ease-in-out;
  100 +}
  101 +
  102 +.yoho-action-sheet {
  103 + .cube-popup-content {
  104 + height: 100%;
  105 + }
  106 +}
  107 +
  108 +.detail {
  109 + position: relative;
  110 +}
  111 +
  112 +</style>
  1 +import YohoActionSheet from './action-sheet';
  2 +
  3 +export default [YohoActionSheet];
@@ -3,11 +3,13 @@ import Images from './images'; @@ -3,11 +3,13 @@ import Images from './images';
3 import Layouts from './layouts'; 3 import Layouts from './layouts';
4 import Products from './products'; 4 import Products from './products';
5 import Comments from './comments'; 5 import Comments from './comments';
  6 +import YohoActionSheet from './action-sheet';
6 7
7 export default [ 8 export default [
8 ...Buttons, 9 ...Buttons,
9 ...Images, 10 ...Images,
10 ...Layouts, 11 ...Layouts,
11 ...Products, 12 ...Products,
12 - ...Comments 13 + ...Comments,
  14 + ...YohoActionSheet
13 ]; 15 ];
@@ -8,16 +8,69 @@ @@ -8,16 +8,69 @@
8 </template> 8 </template>
9 9
10 <script> 10 <script>
  11 +
  12 +import {Scroll, Loading} from 'cube-ui';
  13 +
11 export default { 14 export default {
12 name: 'ArticlePage', 15 name: 'ArticlePage',
  16 + components: {
  17 + Loading,
  18 + Scroll
  19 + },
13 data() { 20 data() {
14 return { 21 return {
15 - shareData: {} 22 + list: [],
  23 + scrollOptions: {
  24 + bounce: false
  25 + }
16 }; 26 };
  27 + },
  28 + methods: {
  29 + click() {
  30 + this.$refs.actionSheet.show();
  31 + setTimeout(() => {
  32 + this.initData();
  33 + this.forceUpdate();
  34 + }, 1000);
  35 + },
  36 + forceUpdate() {
  37 + this.$refs.scroll.forceUpdate();
  38 + },
  39 + initData() {
  40 + for (let i = 0; i < 100; i++) {
  41 + this.list.push(i);
  42 + }
  43 + }
  44 +
17 } 45 }
18 }; 46 };
19 </script> 47 </script>
20 48
21 <style> 49 <style>
  50 + .page {
  51 + position: absolute;
  52 + top: 0;
  53 + left: 0;
  54 + right: 0;
  55 + bottom: 0;
  56 + background-color: gray;
  57 + }
  58 +
  59 + .content {
  60 + width: 100%;
  61 + height: 100vh;
  62 + background-color: white;
  63 + }
  64 +
  65 + .item {
  66 + background-color: white;
  67 + }
  68 +
  69 + .loading {
  70 + position: absolute;
  71 + left: 50%;
  72 + top: 50%;
  73 + transform: translate(-50%, -50%);
  74 + }
22 75
23 </style> 76 </style>