Skip to content

Commit a050b6b

Browse files
Alpsli彧衡陌缓
authored
feat(swiper): support the swiper adjustHeight attribute (#117)
* feat(swiper): support the swiper adjustHeight attribute * feat(Tabs): support more swiper related props * chore(doc): Loading add chinese name Co-authored-by: 彧衡 <[email protected]> Co-authored-by: 陌缓 <[email protected]>
1 parent 2850698 commit a050b6b

File tree

7 files changed

+130
-49
lines changed

7 files changed

+130
-49
lines changed

docs/guide/cooperation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ antd-mini 的发展离不开社区的每一位用户,这里有一些信息可
2424

2525
- 设备信息、客户端版本、组件库版本、组件等
2626
- 你期望的组件行为是什么,实际上组件的行为是什么
27-
- 详细描述复习步骤
27+
- 详细描述复现步骤
2828
- 尽可能提供能够复现 demo 以方便我们快速定位问题
2929

3030
### 贡献代码

src/Loading/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ group:
66
toc: false
77
---
88

9-
# Loading
10-
加载,用于提示局部或页面在加载中。
9+
# Loading 加载
10+
用于提示局部或页面在加载中。
1111

1212
## 代码示例
1313
### 基本使用

src/Tabs/index.axml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@
7474
disable-update-direction="{{true}}"
7575
id="amd-tabs-content-{{$id}}"
7676
class="amd-tabs-content {{_tabContentHeight ? 'amd-tabs-content_H100': ''}}"
77-
adjust-height='current'
77+
adjust-height="{{adjustHeight}}"
78+
active-class="{{activeClass}}"
79+
previous-margin="{{previousMargin}}"
80+
next-margin="{{nextMargin}}"
81+
easing-function="{{easingFunction}}"
82+
snap-to-edge="{{snapToEdge}}"
83+
onAnimationEnd="handleAnimationEnd"
7884
onChange="handleSwiperChange"
7985
onTouchStart="handleSwiperTouchStart"
8086
onTransition="handleSwiperTransition"

src/Tabs/index.md

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,23 @@ toc: false
3030
#### Tabs
3131
| 属性 | 类型 | 必填 | 默认值 | 说明 |
3232
| -----|-----|-----|-----|----- |
33-
| type | 'basis' &verbar; 'capsule' &verbar; 'mixin' &verbar; 'title' || 'basis' | 类型,basis(基础),capsule(胶囊),mixin(混合) |
34-
| index | number || 0 | 当前激活的索引 |
33+
| adjustHeight | string || 'current' | 自动以指定滑块的高度为整个容器的高度 |
34+
| activeClass | string || '' | swiper-item 可见时的 class |
3535
| animation | boolean || false | 是否有过渡动画 |
36-
| swipeable | boolean || false | 是否支持手势切换 |
36+
| className | string || - | 类名 |
37+
| easingFunction | string || 'default' | 切换缓动动画类型 |
38+
| index | number || 0 | 当前激活的索引 |
39+
| nextMargin | string || '0px' | 后边距,单位 px,1.9.0 暂时只支持水平方向 |
40+
| plus | string &verbar; slot || - | 右上角操作按钮,自定义节点 |
41+
| previousMargin | string || '0px' | 前边距,单位 px,1.9.0 暂时只支持水平方向 |
42+
| snapToEdge | boolean || false | 当 swiper-item 个数大于等于 2,关闭 circular 并且开启 previous-margin 或 next-margin 时,可以指定这个边距是否应用到第一个、最后一个元素 |
3743
| sticky | boolean || false | 是否支持吸顶 |
38-
| touchAngle | number || 45 | 用户左右滑动手势生效的滑动角度。角度根据 touchstart 事件和首次 touchmove 事件的坐标计算得出。数值越小越对用户的滑动方向准确度要求越高 |
3944
| swipeRatio | number || 0.2 | 用户左右滑动手势触发切换的阈值,当滑动距离超过阈值时进行 `swiper-item` 切换 |
4045
| swipeSpeed | number || 0.05 | 用户左右滑动手势对应的滑动距离,数值越小则需要用户手势相同位移下 `swiper-item` 位移越小 |
41-
| plus | string &verbar; slot || - | 右上角操作按钮,自定义节点 |
46+
| swipeable | boolean || false | 是否支持手势切换 |
4247
| title | slot-scope || - | 自定义 tab 标题样式,仅在 type 为 basis 时可用 |
43-
| className | string || - | 类名 |
48+
| touchAngle | number || 45 | 用户左右滑动手势生效的滑动角度。角度根据 touchstart 事件和首次 touchmove 事件的坐标计算得出。数值越小越对用户的滑动方向准确度要求越高 |
49+
| type | 'basis' &verbar; 'capsule' &verbar; 'mixin' &verbar; 'title' || 'basis' | 类型,basis(基础),capsule(胶囊),mixin(混合) |
4450

4551
#### TabItem
4652
| 属性 | 类型 | 必填 | 默认值 | 说明 |
@@ -54,6 +60,9 @@ toc: false
5460
| 事件名 | 说明 | 类型 |
5561
| -----|-----|-----|
5662
| onChange | 面板切换时候,触发回调 |(index: number) => void|
63+
| onAnimationEnd | 内部 swiper 组件的 onAnimationEnd 事件(仅在基础库 1.50.0 以上版本生效)|(e: any) => void=> void|
64+
| onTouchStart | 内部 swiper 组件的 onTouchStart 事件(仅在基础库 2.x 版本生效) |(e: any) => void|
65+
| onTransition | 内部 swiper 组件的 onTransition 事件(仅在基础库 2.x 版本生效) |(e: any) => void|
5766

5867
## 插槽
5968
#### Tabs
@@ -101,28 +110,28 @@ toc: false
101110

102111

103112
<style>
104-
table th:first-of-type { width: 180px; }
105-
.__dumi-default-layout-content article table:first-of-type th:nth-of-type(2) {
106-
width: 140px
107-
}
108-
.__dumi-default-layout-content article table:first-of-type th:nth-of-type(3) {
109-
width: 30px
110-
}
111-
.__dumi-default-layout-content article table:first-of-type th:nth-of-type(4) {
112-
width: 50px
113-
}
114-
.__dumi-default-layout-content article table:nth-of-type(2) th:nth-of-type(2) {
115-
width: 140px
116-
}
117-
.__dumi-default-layout-content article table:nth-of-type(2) th:nth-of-type(3) {
118-
width: 30px
119-
}
120-
.__dumi-default-layout-content article table:nth-of-type(2) th:nth-of-type(4) {
121-
width: 50px
122-
}
123-
.__dumi-default-layout-content article table:nth-of-type(6) th:nth-of-type(2) {
124-
width: 300px
125-
}
113+
table th:first-of-type { width: 180px; }
114+
.__dumi-default-layout-content article table:first-of-type th:nth-of-type(2) {
115+
width: 140px;
116+
}
117+
.__dumi-default-layout-content article table:first-of-type th:nth-of-type(3) {
118+
width: 30px;
119+
}
120+
.__dumi-default-layout-content article table:first-of-type th:nth-of-type(4) {
121+
width: 50px;
122+
}
123+
.__dumi-default-layout-content article table:nth-of-type(2) th:nth-of-type(2) {
124+
width: 140px;
125+
}
126+
.__dumi-default-layout-content article table:nth-of-type(2) th:nth-of-type(3) {
127+
width: 30px;
128+
}
129+
.__dumi-default-layout-content article table:nth-of-type(2) th:nth-of-type(4) {
130+
width: 50px;
131+
}
132+
.__dumi-default-layout-content article table:nth-of-type(6) th:nth-of-type(2) {
133+
width: 300px;
134+
}
126135
.__dumi-default-mobile-previewer:nth-of-type(2)::after {
127136
border-bottom: none!important;
128137
}

src/Tabs/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ Component({
260260
onTransition(e)
261261
}
262262
},
263+
handleAnimationEnd(e) {
264+
const { onAnimationEnd } = this.props;
265+
if (typeof onAnimationEnd === "function") {
266+
onAnimationEnd(e)
267+
}
268+
},
263269
appearLeft() {
264270
this.setData({
265271
_leftFade: false,

src/Tabs/props.d.ts

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,123 @@ export interface ITabsProps extends IBaseProps {
1010
* @default "basis"
1111
*/
1212
uid: string;
13+
14+
/**
15+
* @description 自动以指定滑块的高度为整个容器的高度
16+
* @default 'current'
17+
*/
18+
adjustHeight: 'first' | 'current' | 'highest' | 'none';
19+
20+
/**
21+
* @description swiper-item 可见时的 class
22+
* @default ''
23+
*/
24+
activeClass: string;
25+
26+
/**
27+
* @description 前边距,单位 px,1.9.0 暂时只支持水平方向。
28+
* @default '0px'
29+
*/
30+
previousMargin: string;
31+
32+
/**
33+
* @description 后边距,单位 px,1.9.0 暂时只支持水平方向。
34+
* @default '0px'
35+
*/
36+
nextMargin: string;
37+
38+
/**
39+
* @description 切换缓动动画类型。
40+
* @default 'default'
41+
*/
42+
easingFunction: string;
43+
44+
/**
45+
* @description 当 swiper-item 个数大于等于 2,关闭 circular 并且开启 previous-margin 或 next-margin 时,可以指定这个边距是否应用到第一个、最后一个元素。
46+
* @default false
47+
*/
48+
snapToEdge: boolean;
49+
1350
/**
1451
* @description 类型,basis(基础),capsule(胶囊),mixin(混合)
1552
* @default "basis"
1653
*/
1754
type?: 'basis' | 'capsule' | 'mixin';
55+
1856
/**
1957
* @description 当前激活的索引
2058
* @default 0
2159
*/
2260
index?: number;
23-
/**
24-
* @description tab 切换时的回调
25-
*/
26-
onChange?: (index: number) => void;
61+
2762
/**
2863
* @description 是否有过渡动画
2964
* @default false
3065
*/
3166
animation?: boolean;
67+
3268
/**
3369
* @description 是否支持手势切换
3470
* @default false
3571
*/
3672
swipeable?: boolean;
73+
3774
/**
3875
* @description 是否支持吸顶
3976
* @default false
4077
*/
4178
sticky?: boolean;
79+
4280
/**
4381
* @description 吸顶高度
4482
* @default 0
4583
*/
4684
stickyTop?: boolean;
47-
/**
48-
* @description 内部 swiper 组件的 onTouchStart 事件(仅在基础库 2.x 版本生效)
49-
* @default 0
50-
*/
51-
onTouchStart?: (e:any) => void;
52-
/**
53-
* @description 内部 swiper 组件的 onTouchStart 事件(仅在基础库 2.x 版本下生效)
54-
* @default 0
55-
*/
56-
onTransition?: (e:any) => void;
85+
5786
/**
5887
* @description 是否自定义实现"轮播",详见 fallback demo
5988
* @default 0
6089
*/
6190
fallback?: boolean;
91+
6292
/**
6393
* @description 用户左右滑动手势生效的滑动角度。角度根据 touchstart 事件和首次 touchmove 事件的坐标计算得出。数值越小越对用户的滑动方向准确度要求越高
6494
* @default 45
6595
*/
6696
touchAngle?: number;
97+
6798
/**
6899
* @description 用户左右滑动手势触发切换的阈值,当滑动距离超过阈值时进行 `swiper-item` 切换
69100
* @default 0.2
70101
*/
71-
swipeRatio?: number
102+
swipeRatio?: number;
103+
72104
/**
73105
* @description 用户左右滑动手势对应的滑动距离,数值越小则需要用户手势相同位移下 `swiper-item` 位移越小
74106
* @default 0.05
75107
*/
76-
swipeSpeed?: number
108+
swipeSpeed?: number;
109+
110+
/**
111+
* @description tab 切换时的回调
112+
*/
113+
onChange?: (index: number) => void;
114+
115+
/**
116+
* @description 内部 swiper 组件的 onTouchStart 事件(仅在基础库 2.x 版本生效)
117+
* @default 0
118+
*/
119+
onTouchStart?: (e: any) => void;
120+
121+
/**
122+
* @description 内部 swiper 组件的 onTransition 事件(仅在基础库 2.x 版本下生效)
123+
* @default 0
124+
*/
125+
onTransition?: (e: any) => void;
126+
127+
/**
128+
* @description 内部 swiper 组件的 onAnimationEnd 事件(仅在基础库 1.50.0 以上版本生效)
129+
*/
130+
onAnimationEnd?: (e: any) => void;
77131
}
78132
export declare const TabsDefaultProps: Partial<ITabsProps>;

src/Tabs/props.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const TabsDefaultProps = {
22
type: 'basis',
3+
adjustHeight: 'current',
34
index: 0,
45
animation: false,
56
swipeable: false,
@@ -10,5 +11,10 @@ export const TabsDefaultProps = {
1011
swipeRatio: 0.2,
1112
swipeSpeed: 0.05,
1213
onGetRef: () => {},
13-
uid: 'tabs'
14+
uid: 'tabs',
15+
activeClass: '',
16+
previousMargin: '0px',
17+
nextMargin: '0px',
18+
easingFunction: 'default',
19+
snapToEdge: false
1420
};

0 commit comments

Comments
 (0)