123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <template>
- <view>
- <text class="example-info">过渡动画,通常用于元素的过渡效果,例如淡隐淡出效果,遮罩层的效果、放大缩小的效果等</text>
- <uni-section title="基础过渡动画" type="line"></uni-section>
- <view class="example-body">
- <button class="transition-button" type="primary" @click="open(['fade'])">fade</button>
- <button class="transition-button" type="primary" @click="open(['slide-top'])">slide-top</button>
- <button class="transition-button" type="primary" @click="open(['slide-left'])">slide-left</button>
- <button class="transition-button" type="primary" @click="open(['slide-right'])">slide-right</button>
- <button class="transition-button" type="primary" @click="open(['slide-bottom'])">slide-bottom</button>
- <button class="transition-button" type="primary" @click="open(['zoom-in','fade'])">zoom-in</button>
- <button class="transition-button" type="primary" @click="open(['zoom-out','fade'])">zoom-out</button>
- </view>
- <uni-section title="组合过渡动画" type="line"></uni-section>
- <view class="example-body">
- <button class="transition-button" type="primary" @click="mask">透明遮罩层</button>
- <button class="transition-button" type="primary" @click="open(['fade','zoom-out','slide-top'])">组合动画示例一</button>
- <button class="transition-button" type="primary" @click="open(['zoom-in','slide-bottom','fade'])">组合动画示例二</button>
- <button class="transition-button" type="primary" @click="open(['slide-left','slide-top','fade'])">组合动画示例三</button>
- </view>
- <!-- 遮罩 -->
- <uni-transition :mode-class="['fade']" :styles="maskClass" :show="show" @click="onTap" />
- <!-- 过渡 -->
- <uni-transition :duration="500" :mode-class="modeClass" :styles="transfromClass" :show="transShow" @click="onTap" @change="change">
- <text class="box">Test</text>
- </uni-transition>
- </view>
- </template>
- <script>
- export default {
- components: {},
- data() {
- return {
- show: false,
- transShow: false,
- modeClass: ['fade'],
- maskClass: {
- 'position': 'fixed',
- 'bottom': 0,
- 'top': 0,
- 'left': 0,
- 'right': 0,
- 'background-color': 'rgba(0, 0, 0, 0.4)'
- },
- transfromClass: {
- 'position': 'fixed',
- 'bottom': 0,
- 'top': 0,
- 'left': 0,
- 'right': 0,
- /* #ifndef APP-NVUE */
- 'display': 'flex',
- /* #endif */
- 'justify-content': 'center',
- 'align-items': 'center'
- }
- }
- },
- onLoad() {},
- methods: {
- mask() {
- this.show = true
- },
- open(mode) {
- this.modeClass = mode
- this.transShow = !this.transShow
- },
- onTap() {
- this.transShow = this.show = false
- },
- change(e) {
- console.log(e.detail);
- }
- }
- }
- </script>
- <style>
- @charset "UTF-8";
- /* 头条小程序组件内不能引入字体 */
- /* #ifdef MP-TOUTIAO */
- @font-face {
- font-family: uniicons;
- font-weight: normal;
- font-style: normal;
- src: url("~@/static/uni.ttf") format("truetype");
- }
- /* #endif */
- /* #ifndef APP-NVUE */
- page {
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- background-color: #efeff4;
- min-height: 100%;
- height: auto;
- }
- view {
- font-size: 14px;
- line-height: inherit;
- }
- .example {
- padding: 0 15px 15px;
- }
- .example-info {
- padding: 15px;
- color: #3b4144;
- background: #ffffff;
- }
- .example-body {
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: center;
- padding: 0;
- font-size: 14px;
- background-color: #ffffff;
- }
- /* #endif */
- .example {
- padding: 0 15px;
- }
- .example-info {
- /* #ifndef APP-NVUE */
- display: block;
- /* #endif */
- padding: 15px;
- color: #3b4144;
- background-color: #ffffff;
- font-size: 14px;
- line-height: 20px;
- }
- .example-info-text {
- font-size: 14px;
- line-height: 20px;
- color: #3b4144;
- }
- .example-body {
- flex-direction: column;
- padding: 15px;
- background-color: #ffffff;
- }
- .word-btn-white {
- font-size: 18px;
- color: #FFFFFF;
- }
- .word-btn {
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- align-items: center;
- justify-content: center;
- border-radius: 6px;
- height: 48px;
- margin: 15px;
- background-color: #007AFF;
- }
- .word-btn--hover {
- background-color: #4ca2ff;
- }
- .example-body {
- padding: 15px 20px;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: flex-start;
- }
- .transition-button {
- /* #ifndef APP-NVUE */
- /* width: 100%; */
- /* #endif */
- padding: 0 15px;
- margin: 10px 5px;
- }
- .box {
- color: #fff;
- width: 100px;
- height: 100px;
- line-height: 100px;
- text-align: center;
- background-color: #4CD964;
- }
- </style>
|