Browse Source

fix: backtop click

richard1015 5 years ago
parent
commit
ad4b620102
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/packages/backtop/backtop.vue

+ 3 - 1
src/packages/backtop/backtop.vue

@@ -123,6 +123,7 @@ export default {
       this.isAnimation && this.duration > 0
         ? this.scrollAnimation()
         : this.scroll();
+      this.$emit("click");
     },
     scrollAnimation() {
       const self = this;
@@ -133,12 +134,13 @@ export default {
         var y = (t * -self.scrollTop) / self.duration + self.scrollTop;
         self.scroll(y);
         cid = self.requestAniFrame()(fn);
-        if (t == self.duration) {
+        if (t == self.duration || y == 0) {
           window.cancelAnimationFrame(cid);
         }
       });
     },
     scroll(y = 0) {
+      console.log(y);
       if (this.scrollEl === window) {
         window.scrollTo(0, y);
       } else {