Skip to content
Snippets Groups Projects
Commit 2e1f36fe authored by Pan's avatar Pan
Browse files

fix[backToTop]: continuous click bug #1007

parent 00d292f6
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,8 @@ export default {
data() {
return {
visible: false,
interval: null
interval: null,
isMoving: false
}
},
mounted() {
......@@ -62,13 +63,16 @@ export default {
this.visible = window.pageYOffset > this.visibilityHeight
},
backToTop() {
if (this.isMoving) return
const start = window.pageYOffset
let i = 0
this.isMoving = true
this.interval = setInterval(() => {
const next = Math.floor(this.easeInOutQuad(10 * i, start, -start, 500))
if (next <= this.backPosition) {
window.scrollTo(0, this.backPosition)
clearInterval(this.interval)
this.isMoving = false
} else {
window.scrollTo(0, next)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment