mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-17 13:20:52 +08:00
fix(modal): update scrollbar timer leak
This commit is contained in:
parent
a5c547537d
commit
5bf8dae762
@ -51,6 +51,17 @@ export default {
|
||||
updateScrollbarTimerId: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
active (newActive) {
|
||||
this.$nextTick().then(() => {
|
||||
if (newActive) {
|
||||
this.updateScrollbar()
|
||||
} else {
|
||||
window.clearTimeout(this.updateScrollbarTimerId)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created () {
|
||||
if (this.active) {
|
||||
this.styleActive = true
|
||||
@ -58,13 +69,6 @@ export default {
|
||||
},
|
||||
mounted () {
|
||||
this.$nextTick().then(this.registerContent)
|
||||
const updateScrollbar = () => {
|
||||
this.updateScrollbarTimerId = window.setTimeout(() => {
|
||||
this.$refs.scrollbar.updateParameters()
|
||||
updateScrollbar()
|
||||
}, 300)
|
||||
}
|
||||
updateScrollbar()
|
||||
},
|
||||
updated () {
|
||||
this.$nextTick().then(this.registerContent)
|
||||
@ -73,6 +77,13 @@ export default {
|
||||
window.clearTimeout(this.updateScrollbarTimerId)
|
||||
},
|
||||
methods: {
|
||||
updateScrollbar () {
|
||||
this.updateScrollbarTimerId = window.setTimeout(() => {
|
||||
// console.log('update scrollbar')
|
||||
this.$refs.scrollbar.updateParameters()
|
||||
this.updateScrollbar()
|
||||
}, 300)
|
||||
},
|
||||
registerContent () {
|
||||
const slots = this.$slots.default
|
||||
const els = slots.map(vNode => vNode.elm).filter(el => el)
|
||||
|
Loading…
Reference in New Issue
Block a user