Skip to content

Commit

Permalink
Backtop: Add backtop component (#15541)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun authored and luckyCao committed May 27, 2019
1 parent 9ea7012 commit 45383cd
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 54 deletions.
1 change: 1 addition & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@
"divider": "./packages/divider/index.js",
"image": "./packages/image/index.js",
"calendar": "./packages/calendar/index.js",
"backtop": "./packages/backtop/index.js",
"infiniteScroll": "./packages/infiniteScroll/index.js"
}
60 changes: 60 additions & 0 deletions examples/docs/en-US/backtop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Backtop

A button to back to top

### Basic usage

Scroll down to see the bottom-right button.
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap"></el-backtop>
</template>
```

:::

### Customizations

Display area is 40px \* 40px.
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap" :bottom="100">
<div
style="{
height: 100%;
width: 100%;
background-color: #f2f5f6;
box-shadow: 0 0 6px rgba(0,0,0, .12);
text-align: center;
line-height: 40px;
color: #1989fa;
}"
>
UP
</div>
</el-backtop>
</template>
```

:::

### Attributes

| Attribute | Description | Type | Accepted Values | Default |
| ----------------- | ------------------------------------------------------------------- | --------------- | --------------- | ------- |
| target | the target to trigger scroll | string | | |
| visibility-height | the button will not show until the scroll height reaches this value | number | | 200 |
| right | right distance | number | | 40 |
| bottom | bottom distance | number | | 40 |

### Events

| Event Name | Description | Parameters |
| ---------- | ------------------- | ----------- |
| click | triggers when click | click event |
60 changes: 60 additions & 0 deletions examples/docs/es/backtop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Backtop

A button to back to top

### Basic usage

Scroll down to see the bottom-right button.
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap"></el-backtop>
</template>
```

:::

### Customizations

Display area is 40px \* 40px.
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap" :bottom="100">
<div
style="{
height: 100%;
width: 100%;
background-color: #f2f5f6;
box-shadow: 0 0 6px rgba(0,0,0, .12);
text-align: center;
line-height: 40px;
color: #1989fa;
}"
>
UP
</div>
</el-backtop>
</template>
```

:::

### Attributes

| Attribute | Description | Type | Accepted Values | Default |
| ----------------- | ------------------------------------------------------------------- | --------------- | --------------- | ------- |
| target | the target to trigger scroll | string | | |
| visibility-height | the button will not show until the scroll height reaches this value | number | | 200 |
| right | right distance | number | | 40 |
| bottom | bottom distance | number | | 40 |

### Events

| Event Name | Description | Parameters |
| ---------- | ------------------- | ----------- |
| click | triggers when click | click event |
60 changes: 60 additions & 0 deletions examples/docs/fr-FR/backtop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Backtop

A button to back to top

### Basic usage

Scroll down to see the bottom-right button.
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap"></el-backtop>
</template>
```

:::

### Customizations

Display area is 40px \* 40px.
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap" :bottom="100">
<div
style="{
height: 100%;
width: 100%;
background-color: #f2f5f6;
box-shadow: 0 0 6px rgba(0,0,0, .12);
text-align: center;
line-height: 40px;
color: #1989fa;
}"
>
UP
</div>
</el-backtop>
</template>
```

:::

### Attributes

| Attribute | Description | Type | Accepted Values | Default |
| ----------------- | ------------------------------------------------------------------- | --------------- | --------------- | ------- |
| target | the target to trigger scroll | string | | |
| visibility-height | the button will not show until the scroll height reaches this value | number | | 200 |
| right | right distance | number | | 40 |
| bottom | bottom distance | number | | 40 |

### Events

| Event Name | Description | Parameters |
| ---------- | ------------------- | ----------- |
| click | triggers when click | click event |
60 changes: 60 additions & 0 deletions examples/docs/zh-CN/backtop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Backtop 回到顶部

返回页面顶部的操作按钮

### 基础用法

滑动页面即可看到右下方的按钮。
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap"></el-backtop>
</template>
```

:::

### 自定义显示内容

显示区域被固定为 40px \* 40px 的区域, 其中的内容可支持自定义。
:::demo

```html
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap" :bottom="100">
<div
style="{
height: 100%;
width: 100%;
background-color: #f2f5f6;
box-shadow: 0 0 6px rgba(0,0,0, .12);
text-align: center;
line-height: 40px;
color: #1989fa;
}"
>
UP
</div>
</el-backtop>
</template>
```

:::

### Attributes

| 参数 | 说明 | 类型 | 可选值 | 默认值 |
| ----------------- | -------------------------------- | --------------- | ------ | ------ |
| target | 触发滚动的对象 | string | | |
| visibility-height | 滚动高度达到此参数值才出现 | number | | 200 |
| right | 控制其显示位置, 距离页面右边距 | number | | 40 |
| bottom | 控制其显示位置, 距离页面底部距离 | number | | 40 |

### Events

| 事件名 | 说明 | 回调参数 |
| ------ | ------------------ | -------- |
| click | 点击按钮触发的事件 | 点击事件 |
16 changes: 16 additions & 0 deletions examples/nav.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@
"path": "/image",
"title": "Image 图片"
},
{
"path": "/backtop",
"title": "Backtop 回到顶部"
},
{
"path": "/infiniteScroll",
"title": "InfiniteScroll 无限滚动"
Expand Down Expand Up @@ -546,6 +550,10 @@
"path": "/image",
"title": "Image"
},
{
"path": "/backtop",
"title": "Backtop"
},
{
"path": "/infiniteScroll",
"title": "InfiniteScroll"
Expand Down Expand Up @@ -824,6 +832,10 @@
"path": "/image",
"title": "Image"
},
{
"path": "/backtop",
"title": "Backtop"
},
{
"path": "/infiniteScroll",
"title": "InfiniteScroll"
Expand Down Expand Up @@ -1102,6 +1114,10 @@
"path": "/image",
"title": "Image"
},
{
"path": "/backtop",
"title": "Backtop"
},
{
"path": "/infiniteScroll",
"title": "InfiniteScroll"
Expand Down
Loading

0 comments on commit 45383cd

Please sign in to comment.