Skip to content

Commit

Permalink
feat(Tabs): add resize method (#5071)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Nov 21, 2019
1 parent 659eb3e commit a1a93ba
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/swipe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ export default {

### Swipe Methods

Use ref to get swipe instance and call instance methods
Use ref to get Swipe instance and call instance methods

| Name | Description | Attribute | Return value |
|------|------|------|------|
| swipeTo | Swipe to target index | index: target index, options: Options | void |
| resize | Resize swipe when container element resized | - | void |
| resize | Resize Swipe when container element resized | - | void |

### swipeTo Options

Expand Down
2 changes: 1 addition & 1 deletion src/swipe/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default {

### Swipe 方法

通过 ref 可以获取到 swipe 实例并调用实例方法
通过 ref 可以获取到 Swipe 实例并调用实例方法

| 方法名 | 说明 | 参数 | 返回值 |
|------|------|------|------|
Expand Down
26 changes: 17 additions & 9 deletions src/tab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content
| to | Target route of the link, same as to of vue-router | *string \| object* | - | 2.2.1 |
| replace | If true, the navigation will not leave a history record | *boolean* | `false` | 2.2.1 |

### Tabs Events

| Event | Description | Arguments |
|------|------|------|
| click | Triggered when click tab | name:name of current tab,title: tab title |
| change | Triggered when active tab changed | name:name of current tab,title: tab title |
| disabled | Triggered when click disabled tab | name:name of current tab, title: tab title |
| scroll | Triggered when tab scroll in sticky mode | object: { scrollTop, isFixed } |

### Tabs Methods

Use ref to get Tabs instance and call instance methods

| Name | Description | Attribute | Return value |
|------|------|------|------|
| resize | Resize Tabs when container element resized | - | void |

### Tabs Slots

| Name | Description |
Expand All @@ -219,12 +236,3 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content
|------|------|
| default | Content of tab |
| title | Custom tab title |

### Tabs Events

| Event | Description | Arguments |
|------|------|------|
| click | Triggered when click tab | name:name of current tab,title: tab title |
| change | Triggered when active tab changed | name:name of current tab,title: tab title |
| disabled | Triggered when click disabled tab | name:name of current tab, title: tab title |
| scroll | Triggered when tab scroll in sticky mode | object: { scrollTop, isFixed } |
26 changes: 17 additions & 9 deletions src/tab/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ export default {
| to | 点击后跳转的目标路由对象,同 vue-router 的 [to 属性](https://router.vuejs.org/zh/api/#to) | *string \| object* | - | 2.2.1 |
| replace | 是否在跳转时替换当前页面历史 | *boolean* | `false` | 2.2.1 |

### Tabs Events

| 事件名 | 说明 | 回调参数 |
|------|------|------|
| click | 点击标签时触发 | name:标签标识符,title:标题 |
| change | 当前激活的标签改变时触发 | name:标签标识符,title:标题 |
| disabled | 点击被禁用的标签时触发 | name:标签标识符,title:标题 |
| scroll | 滚动时触发,仅在 sticky 模式下生效 | { scrollTop: 距离顶部位置, isFixed: 是否吸顶 } |

### Tabs 方法

通过 ref 可以获取到 Tabs 实例并调用实例方法

| 方法名 | 说明 | 参数 | 返回值 |
|------|------|------|------|
| resize | 外层元素大小变化后,可以调用此方法来触发重绘 | - | void |

### Tabs Slots

| 名称 | 说明 |
Expand All @@ -223,12 +240,3 @@ export default {
|------|------|
| default | 标签页内容 |
| title | 自定义标题,不支持动态渲染 |

### Tabs Events

| 事件名 | 说明 | 回调参数 |
|------|------|------|
| click | 点击标签时触发 | name:标签标识符,title:标题 |
| change | 当前激活的标签改变时触发 | name:标签标识符,title:标题 |
| disabled | 点击被禁用的标签时触发 | name:标签标识符,title:标题 |
| scroll | 滚动时触发,仅在 sticky 模式下生效 | { scrollTop: 距离顶部位置, isFixed: 是否吸顶 } |
7 changes: 6 additions & 1 deletion src/tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default createComponent({
mixins: [
ParentMixin('vanTabs'),
BindEventMixin(function(bind) {
bind(window, 'resize', this.setLine, true);
bind(window, 'resize', this.resize, true);
})
],

Expand Down Expand Up @@ -139,6 +139,11 @@ export default createComponent({
},

methods: {
// @exposed-api
resize() {
this.setLine();
},

onShow() {
this.$nextTick(() => {
this.inited = true;
Expand Down

0 comments on commit a1a93ba

Please sign in to comment.