From 6c5315f0b1bf77773fc0ff24c14881d812ff8f02 Mon Sep 17 00:00:00 2001
From: kooriookami <38392315+kooriookami@users.noreply.github.com>
Date: Sun, 31 Jan 2021 02:43:49 -0600
Subject: [PATCH] feat(Sticky): support sticky to bottom (#7979)
---
src/sticky/README.md | 10 +
src/sticky/README.zh-CN.md | 12 ++
src/sticky/demo/index.vue | 11 ++
src/sticky/index.less | 3 -
src/sticky/index.tsx | 93 +++++----
.../test/__snapshots__/demo.spec.js.snap | 18 ++
.../test/__snapshots__/index.spec.js.snap | 58 ++++--
src/sticky/test/index.spec.js | 176 ++++++++++++++++--
8 files changed, 314 insertions(+), 67 deletions(-)
diff --git a/src/sticky/README.md b/src/sticky/README.md
index ecf138340..b96ba64ff 100644
--- a/src/sticky/README.md
+++ b/src/sticky/README.md
@@ -38,6 +38,14 @@ app.use(Sticky);
```
+### Offset Bottom
+
+```html
+
+ Offset Bottom
+
+```
+
```js
export default {
setup() {
@@ -54,6 +62,8 @@ export default {
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| offset-top | Offset top, supports `px` `vw` `vh` `rem` unit, default `px` | _number \| string_ | `0` |
+| offset-bottom | Offset bottom, supports `px` `vw` `vh` `rem` unit, default `px` | _number \| string_ | `0` |
+| position | Offset position, supports `top` `bottom` | _string_ | `top` |
| z-index | z-index when sticky | _number \| string_ | `99` |
| container | Container DOM | _Element_ | - |
diff --git a/src/sticky/README.zh-CN.md b/src/sticky/README.zh-CN.md
index 031bb30bc..a80e8f018 100644
--- a/src/sticky/README.zh-CN.md
+++ b/src/sticky/README.zh-CN.md
@@ -48,6 +48,16 @@ app.use(Sticky);
```
+### 吸底距离
+
+通过 `offset-bottom` 属性可以设置组件在吸底时与底部的距离。通过 `position` 属性控制吸附位置,默认值为 `top`。
+
+```html
+
+ 吸底距离
+
+```
+
```js
export default {
setup() {
@@ -64,6 +74,8 @@ export default {
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| offset-top | 吸顶时与顶部的距离,支持 `px` `vw` `vh` `rem` 单位,默认 `px` | _number \| string_ | `0` |
+| offset-bottom | 吸底时与底部的距离,支持 `px` `vw` `vh` `rem` 单位,默认 `px` | _number \| string_ | `0` |
+| position | 吸附位置,支持 `top` `bottom` | _string_ | `top` |
| z-index | 吸顶时的 z-index | _number \| string_ | `99` |
| container | 容器对应的 HTML 节点 | _Element_ | - |
diff --git a/src/sticky/demo/index.vue b/src/sticky/demo/index.vue
index 9f0ad7f78..4ca62a1a8 100644
--- a/src/sticky/demo/index.vue
+++ b/src/sticky/demo/index.vue
@@ -24,6 +24,15 @@
+
+
+
+
+
+ {{ t('offsetBottom') }}
+
+
+