Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AnchorSmooth,GoTop]:添加两个锚点相关的功能,以及中英文版的markdown文档使用说明。 #945

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
86 changes: 86 additions & 0 deletions site/docs/en-US/anchor-smooth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## AnchorSmooth

A label slide to anchor point.

### Basic usage

Similar to the use of a tag, the attribute targetId is used to indicate the anchor that you want to reach.

::: demo The AnchorSmooth component provides `targetId` attributes to point to ID elements that exist in the page and must have values. If the child element does not exist, `targetId` is used as the child element.
```js
render() {
return (
<div>
<div className='anchor-point' id='anchor0'>Here is the anchor#anchor0</div>
<div className='anchor-group'>
<AnchorSmooth targetId='anchor1' />
<AnchorSmooth targetId='anchor1'>
Slide to anchor#anchor1
</AnchorSmooth>
</div>
</div>
)
}
```
:::

### callback

The attribute `onFinish` can bind a callback function and execute the callback function after reaching the anchor point.

::: demo In the AnchorSmooth component, you can set the `onFinish` callback function that completes the sliding, and then call the `onFinish` function when it reaches the anchor.
```js
render() {
return (
<div>
<div id='anchor1' className='anchor-point'>
Here is the anchor#anchor1
</div>
<AnchorSmooth
targetId='anchor2'
onFinish={() => console.log("Arrive at anchor2")}>
Go to the anchor with ID anchor2 and execute the callback function
</AnchorSmooth>
</div>
)
}
```
:::

### set title

The` title` property tells the user the anchor to go when the mouse moves in.

::: demo Use the `title` attribute to describe an anchor.
```js
render() {
return (
<div>
<div id='anchor2' className='anchor-point'>
Here is the anchor#anchor2
</div>
<AnchorSmooth
targetId='anchor0'
title="go to anchor0"
onFinish={() => console.log("Arrive at anchor0")}>
To the anchor with ID anchor0, containing title
</AnchorSmooth>
</div>
)
}
```
:::

### Attributes

| Attribute | Description | Type | Accepted Values | Default |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| **targetId** | Anchor target **REQUIRED** | string | — | — |
| title | title | string | — | — |

### Events

| Event Name | Description | Parameters |
|---------- |-------- |---------- |
| onFinish | fires when anchor is arrived | — |

120 changes: 120 additions & 0 deletions site/docs/en-US/go-top.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
## GoTop

In a long page, you can go back to the top of the page by clicking on the button from the bottom to the top.

### Basic usage

Usually the top-back button appears in the lower right corner of the page, so it is recommended to modify the `right`, `bottom` attributes for positioning; if there are special needs, you can also modify the `left`, `top` attributes.

::: demo In the GoTop component, you can modify the `right` and `bottom` attributes with the default values of right: 50px and bottom: 50px.
```js
render() {
return (
<div>
<h3>Basic usage: The first button in the lower right corner</h3>
<GoTop bottom="360px" showheight={0}/>
</div>
)
}
```
:::

### Property `showheight`

Usually the top button will not appear when the rolling distance is 0. We can define the height of the scrollbar when the button appears by the attribute `showheight`, with the default value of 300, per unit px. If the scroll distance is greater than 300, the display button will fade in; if the scroll distance is less than 300, the hidden button will fade out.

::: demo In the GoTop component, you can modify the showheight property to specify the scroll distance of the scrollbar, default value: 300; type: number.

```js
render() {
return (
<div>
<h3>
A button appears when the scroll distance is 200 px:
the second button in the lower right corner
</h3>
<GoTop bottom="300px" showheight={200}/>
</div>
)
}
```

:::

### With icon

By default, the `el-icon-caret-top` in elementUI can be used to replace the default icon by setting sub-elements.

::: demo By setting the` children` attribute to display GoTop's icon, you can more effectively show the user your display intentions.
```js
render() {
return (
<div>
<h3>With icon:The third button in the lower right corner</h3>
<GoTop bottom="240px">
<i className="el-icon-arrow-up"></i>
</GoTop>
</div>
)
}
```
:::

### Sliding time and callback function

Customize the time used to complete the sliding, attribute: `time`, default value: 300, unit: Ms.

::: demo In the GoTop component, you can set the `time` needed to complete the sliding and call an `onFinish` callback function when you reach the anchor.

```js
render() {
return (
<div>
<h3>
Custom sliding time and callback function:
The fourth button in the lower right corner
</h3>
<GoTop bottom="180px" time={800}
onFinish={() => console.log("go to top")}/>
</div>
)
}
```

:::

### Set title

The` title` property tells the user the anchor to go when the mouse moves in.

::: demo Use the `title` attribute to describe an anchor.

```js
render() {
return (
<div>
<h3>Title: the fifth button in the lower right corner</h3>
<GoTop bottom="120px" title="go to top" />
</div>
)
}
```

:::

### Attributes
| Attribute | Description | Type | Accepted Values | Default |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| showheight | Scrollbar Scroll Distance Threshold, Unit PX | number | — | 300 |
| time | The time required to reach the top, unit MS | number | — | 300 |
| title | title | string | — | — |
| right | Distance to the rightof the page | string | — | 50px |
| bottom | Distance to the bottom of the page | string | — | 50px |
| top | Distance to the top of the page | string | — | — |
| left | Distance to the left of the page | string | — | — |

### Events

| Event Name | Description | Parameters |
| ---------- | ---------------------------- | ---------- |
| onFinish | fires when anchor is arrived | — |
85 changes: 85 additions & 0 deletions site/docs/zh-CN/anchor-smooth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## AnchorSmooth 滑向锚点

用于a标签滑向锚点。

### 基本用法

和a标签用法类似,使用属性`targetId`表明想到达的锚点。

::: demo AnchorSmooth 组件提供`targetId`属性指向页面中**存在id元素**,必须值。若子元素不存在,则使用`targetId`当作子元素。
```js
render() {
return (
<div>
<div className='anchor-point' id='anchor0'>这里是锚点#anchor0</div>
<div className='anchor-group'>
<AnchorSmooth targetId='anchor1' />
<AnchorSmooth targetId='anchor1'>
滑动到锚点anchor1
</AnchorSmooth>
</div>
</div>
)
}
```
:::

### 回调函数

属性`onFinish`可在绑定一个回调函数,在到达锚点后执行回调函数。

::: demo 在 AnchorSmooth 组件中,你可以设置完成滑动完成的回调函数`onFinish`,到达锚点之后会调用`onFinish`函数。
```js
render() {
return (
<div>
<div id='anchor1' className='anchor-point'>
这里是锚点#anchor1
</div>
<AnchorSmooth
targetId='anchor2'
onFinish={() => console.log("Arrive at anchor2")}>
到id为anchor2的锚点,并执行回调函数
</AnchorSmooth>
</div>
)
}
```
:::

### 设置标题

`title`属性,鼠标移入时告诉用户即将去的锚点。

::: demo 使用`title`属性来描述一个锚点。
```js
render() {
return (
<div>
<div id='anchor2' className='anchor-point'>
这里是锚点#anchor2
</div>
<AnchorSmooth
targetId='anchor0'
title="go to anchor0"
onFinish={() => console.log("Arrive at anchor0")}>
到id为anchor0的锚点,包含title
</AnchorSmooth>
</div>
)
}
```
:::

### Attributes

| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| **targetId** | 锚点目标,页面中需要有对应id,**必选参数** | string | — | — |
| title | 辅助性文字 | string | — | — |

### Events

| 事件名称 | 说明 | 回调参数 |
|---------- |-------- |---------- |
| onFinish | 锚点到达时的回调函数 | — |
Loading