• 引入
  • 代码演示
    • 动画
  • API

    Transition 动画

    Scan me!

    复用动画切换组件

    引入

    1. import { Transition } from 'mand-mobile'
    2. Vue.component(Transition.name, Transition)

    代码演示

    动画

    Transition 动画 - 图2

    1. <template>
    2. <div class="md-example-child md-example-child-transition md-example-child-transition-1">
    3. <md-button @click="showPopUp(0)">Fade</md-button>
    4. <md-popup
    5. v-model="isPopupShow[0]"
    6. transition="md-fade"
    7. >
    8. <div class="md-example-popup md-example-popup-center">
    9. Fade
    10. </div>
    11. </md-popup>
    12. <md-button @click="showPopUp(1)">Fade Up</md-button>
    13. <md-popup
    14. v-model="isPopupShow[1]"
    15. transition="md-fade-up"
    16. >
    17. <div class="md-example-popup md-example-popup-center">
    18. Fade Up
    19. </div>
    20. </md-popup>
    21. <md-button @click="showPopUp(2)">Fade Down</md-button>
    22. <md-popup
    23. v-model="isPopupShow[2]"
    24. transition="md-fade-down"
    25. >
    26. <div class="md-example-popup md-example-popup-center">
    27. Fade Down
    28. </div>
    29. </md-popup>
    30. <md-button @click="showPopUp(3)">Fade Left</md-button>
    31. <md-popup
    32. v-model="isPopupShow[3]"
    33. transition="md-fade-left"
    34. >
    35. <div class="md-example-popup md-example-popup-center">
    36. Fade Left
    37. </div>
    38. </md-popup>
    39. <md-button @click="showPopUp(4)">Fade Right</md-button>
    40. <md-popup
    41. v-model="isPopupShow[4]"
    42. transition="md-fade-right"
    43. >
    44. <div class="md-example-popup md-example-popup-center">
    45. Fade Right
    46. </div>
    47. </md-popup>
    48. <md-button @click="showPopUp(5)">Bounce</md-button>
    49. <md-popup
    50. v-model="isPopupShow[5]"
    51. transition="md-bounce"
    52. >
    53. <div class="md-example-popup md-example-popup-center">
    54. Bounce
    55. </div>
    56. </md-popup>
    57. <md-button @click="showPopUp(6)">Punch</md-button>
    58. <md-popup
    59. v-model="isPopupShow[6]"
    60. transition="md-punch"
    61. >
    62. <div class="md-example-popup md-example-popup-center">
    63. Punch
    64. </div>
    65. </md-popup>
    66. <md-button @click="showPopUp(7)">Zoom</md-button>
    67. <md-popup
    68. v-model="isPopupShow[7]"
    69. transition="md-zoom"
    70. >
    71. <div class="md-example-popup md-example-popup-center">
    72. Zoom
    73. </div>
    74. </md-popup>
    75. <md-button @click="showPopUp(8)">Slide Up</md-button>
    76. <md-popup
    77. v-model="isPopupShow[8]"
    78. transition="md-slide-up"
    79. >
    80. <div class="md-example-popup md-example-popup-center">
    81. Slide Up
    82. </div>
    83. </md-popup>
    84. <md-button @click="showPopUp(9)">Slide Down</md-button>
    85. <md-popup
    86. v-model="isPopupShow[9]"
    87. transition="md-slide-down"
    88. >
    89. <div class="md-example-popup md-example-popup-center">
    90. Slide Down
    91. </div>
    92. </md-popup>
    93. <md-button @click="showPopUp(10)">Slide Left</md-button>
    94. <md-popup
    95. v-model="isPopupShow[10]"
    96. transition="md-slide-left"
    97. >
    98. <div class="md-example-popup md-example-popup-center">
    99. Slide Left
    100. </div>
    101. </md-popup>
    102. <md-button @click="showPopUp(11)">Slide Right</md-button>
    103. <md-popup
    104. v-model="isPopupShow[11]"
    105. transition="md-slide-right"
    106. >
    107. <div class="md-example-popup md-example-popup-center">
    108. Slide Right
    109. </div>
    110. </md-popup>
    111. </div>
    112. </template>
    113. <script>
    114. import {Popup, Button} from 'mand-mobile'
    115. export default {
    116. name: 'transition-demo',
    117. components: {
    118. [Popup.name]: Popup,
    119. [Button.name]: Button,
    120. },
    121. data() {
    122. return {
    123. isPopupShow: [],
    124. }
    125. },
    126. methods: {
    127. showPopUp(type) {
    128. this.$set(this.isPopupShow, type, true)
    129. },
    130. },
    131. }
    132. </script>
    133. <style lang="stylus">
    134. .md-example-child-transition-1
    135. float left
    136. width 100%
    137. .md-button
    138. margin-bottom 20px
    139. .md-example-popup
    140. position relative
    141. font-size 28px
    142. font-family DINAlternate-Bold
    143. font-weight 500
    144. box-sizing border-box
    145. text-align center
    146. background-color #FFF
    147. .md-example-popup-center
    148. padding 50px
    149. border-radius radius-normal
    150. </style>
    151.  

    API

    md-transition组件为Vue内置transtion的一层封装,支持所有Transition的属性参数。

    其中内置动画name参数如下:

    • md-fade
    • md-fade-up
    • md-fade-down
    • md-fade-left
    • md-fade-right
    • md-slide-up
    • md-slide-down
    • md-slide-left
    • md-slide-right
    • md-bounce
    • md-punch
    • md-zoom