bug fix and performance improvements
This commit is contained in:
@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Transition 过渡
|
||||
description: 过渡组件。
|
||||
spline: message
|
||||
isComponent: true
|
||||
---
|
||||
|
||||
## 引入
|
||||
|
||||
### 引入组件
|
||||
|
||||
在 `app.json` 或 `page.json` 中引入组件:
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-transition": "tdesign-miniprogram/transition/transition"
|
||||
}
|
||||
```
|
||||
|
||||
## 用法
|
||||
|
||||
### 组件方式
|
||||
|
||||
```xml
|
||||
<!-- page.wxml -->
|
||||
<t-transition
|
||||
name="transition-class"
|
||||
visible="{{ visible }}"
|
||||
>
|
||||
<view class="block" style="width: 100px; height: 100px; background: red;"></view>
|
||||
</t-transition>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `<transition>` 组件
|
||||
|
||||
组件路径:`tdesign-miniprogram/transition/transition`
|
||||
|
||||
### 过渡类名
|
||||
|
||||
过渡类名指定格式同 vue,enter/enter-to leave/leave-to
|
||||
|
||||
#### Props
|
||||
|
||||
| 属性 | 值类型 | 默认值 | 说明 |
|
||||
| ------------- | ---------------- | -------------- | --------------------------- |
|
||||
| name | String | 't-transition' | 过渡类名,类似 vue 过渡类名 |
|
||||
| visible | Boolean | false | 是否显示 |
|
||||
| customClass | String | false | 自定义容器类名 |
|
||||
| destoryOnHide | Boolean | false | 隐藏之后是否渲染 slot 内容 |
|
||||
| appear | Boolean | false | 首次出现是否展示动画 |
|
||||
| durations | Number / Boolean | | 手动指定过渡时间 |
|
||||
2
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/index.d.ts
vendored
Normal file
2
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/index.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './props';
|
||||
export * from './type';
|
||||
@ -0,0 +1,2 @@
|
||||
export * from './props';
|
||||
export * from './type';
|
||||
3
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/props.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/props.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TdTransitionProps } from './type';
|
||||
declare const props: TdTransitionProps;
|
||||
export default props;
|
||||
@ -0,0 +1,26 @@
|
||||
const props = {
|
||||
appear: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
customClass: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
destoryOnClose: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
value: 't-transition',
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
8
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/transition.d.ts
vendored
Normal file
8
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/transition.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class Transition extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
behaviors: string[];
|
||||
data: {
|
||||
classPrefix: string;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
import { SuperComponent, wxComponent } from '../common/src/index';
|
||||
import transition from '../mixins/transition';
|
||||
import config from '../common/config';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-transition`;
|
||||
let Transition = class Transition extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.externalClasses = [`${prefix}-class`];
|
||||
this.behaviors = [transition()];
|
||||
this.data = {
|
||||
classPrefix: name,
|
||||
};
|
||||
}
|
||||
};
|
||||
Transition = __decorate([
|
||||
wxComponent()
|
||||
], Transition);
|
||||
export default Transition;
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<wxs src="../common/utils.wxs" module="_" />
|
||||
|
||||
<view
|
||||
class="class {{prefix}}-class {{classPrefix}} {{ transitionClass }}"
|
||||
style="{{_._style([visible ? '' : 'display: none', style, customStyle])}}"
|
||||
bind:transitionend="onTransitionEnd"
|
||||
>
|
||||
<slot />
|
||||
</view>
|
||||
@ -0,0 +1,14 @@
|
||||
.t-transition-enter {
|
||||
opacity: 0;
|
||||
}
|
||||
.t-transition-enter-to {
|
||||
opacity: 1;
|
||||
transition: opacity 1s;
|
||||
}
|
||||
.t-transition-leave {
|
||||
opacity: 1;
|
||||
}
|
||||
.t-transition-leave-to {
|
||||
opacity: 0;
|
||||
transition: opacity 1s;
|
||||
}
|
||||
26
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/type.d.ts
vendored
Normal file
26
miniprogram/miniprogram_npm/tdesign-miniprogram/transition/type.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
export interface TdTransitionProps {
|
||||
appear?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
customClass?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
destoryOnClose?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
duration?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
name?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
visible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
;
|
||||
export {};
|
||||
Reference in New Issue
Block a user