mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Sticky): offset-top can be string
This commit is contained in:
parent
3cc99b3abe
commit
3c2afab6d8
@ -56,9 +56,9 @@ export default {
|
||||
|
||||
| Attribute | Description | Type | Default |
|
||||
|------|------|------|------|
|
||||
| offset-top | Offset top | *number* | `0` |
|
||||
| offset-top | Offset top | *number \| string* | `0` |
|
||||
| z-index | z-index when sticky | *number \| string* | `99` |
|
||||
| container | Container DOM | *HTMLElement* | - |
|
||||
| container | Container DOM | *Element* | - |
|
||||
|
||||
### Events
|
||||
|
||||
|
@ -66,9 +66,9 @@ export default {
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------|------|------|------|
|
||||
| offset-top | 吸顶时与顶部的距离,单位`px` | *number* | `0` |
|
||||
| offset-top | 吸顶时与顶部的距离,单位`px` | *number \| string* | `0` |
|
||||
| z-index | 吸顶时的 z-index | *number \| string* | `99` |
|
||||
| container | 容器对应的 HTML 节点 | *HTMLElement* | - |
|
||||
| container | 容器对应的 HTML 节点 | *Element* | - |
|
||||
|
||||
### Events
|
||||
|
||||
|
@ -20,7 +20,7 @@ export default createComponent({
|
||||
zIndex: [Number, String],
|
||||
container: null,
|
||||
offsetTop: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
@ -61,7 +61,8 @@ export default createComponent({
|
||||
onScroll() {
|
||||
this.height = this.$el.offsetHeight;
|
||||
|
||||
const { container, offsetTop } = this;
|
||||
const { container } = this;
|
||||
const offsetTop = +this.offsetTop;
|
||||
const scrollTop = getScrollTop(window);
|
||||
const topToPageTop = getElementTop(this.$el);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user