fix(anchor, backtop)

This commit is contained in:
songwanli2025@163.com 2020-02-19 11:42:31 +08:00
parent c6417ac3e5
commit 52be5e2d00
3 changed files with 7 additions and 11 deletions

View File

@ -14,7 +14,7 @@ scrollto
|affix|`boolean`|`false`|Anchor 是否像 Affix 一样展示,如果设定为 `true`,它还会接受 [Affix](n-affix#Props) 的 Props|
|target|`() => HTMLElement`|一个返回最邻近可滚动祖先元素的函数|需要监听滚动的元素(如果你希望 Anchor 和 Affix 分别监听不同的元素,可以手动的组合 Anchor 和 Affix|
|bound|`number`|`12`||
||ignoreGap|`boolean`|`false`| 如果设定为 `true`, 导航将显示在准确的href区域 |
|ignoreGap|`boolean`|`false`| 如果设定为 `true`, 导航将显示在准确的href区域 |
## Methods

View File

@ -5,7 +5,7 @@
v-if="show"
:class="{
[`n-${syntheticTheme}-theme`]: syntheticTheme,
'n-back-top--no-transition': transitionDisabled
'n-back-top--transition-disabled': transitionDisabled
}"
:style="{
...syntheticStyle,
@ -82,9 +82,7 @@ export default {
return this.bottom + 'px'
},
show () {
if (this.scrollTop === 0) {
return false
} else if (this.scrollTop >= this.visibilityHeight) {
if (this.scrollTop >= this.visibilityHeight) {
return true
} else {
return false
@ -99,11 +97,11 @@ export default {
},
mounted () {
this.$refs.portal.transferElement()
this.transitionDisabled = !!this.show
this.transitionDisabled = this.show
},
beforeDestroy () {
if (this.container) {
this.container.removeEventListener('scroll', this.handleScroll, true)
this.container.removeEventListener('scroll', this.handleScroll)
}
},
methods: {
@ -114,9 +112,7 @@ export default {
this.container = getScrollParent(this.$el)
}
if (this.container) {
this.container.addEventListener('scroll', () => {
this.handleScroll()
}, true)
this.container.addEventListener('scroll', this.handleScroll)
this.handleScroll()
}
},

View File

@ -32,7 +32,7 @@
fill: $--back-top-button-fill-active;
}
}
@include m(no-transition) {
@include m(transition-disabled) {
transition: none !important;
}
}