File tree Expand file tree Collapse file tree 1 file changed +1
-24
lines changed
packages/@vuepress-reco/vuepress-plugin-back-to-top/bin Expand file tree Collapse file tree 1 file changed +1
-24
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,6 @@ export default {
1212 data () {
1313 return {
1414 visible: false ,
15- interval: null ,
16- isMoving: false ,
1715 /* eslint-disable no-undef */
1816 customStyle: CUSTOM_STYLE ,
1917 visibilityHeight: VISIBILITY_HEIGHT
@@ -24,34 +22,13 @@ export default {
2422 },
2523 beforeDestroy () {
2624 window .removeEventListener (' scroll' , this .handleScroll )
27- if (this .interval ) {
28- clearInterval (this .interval )
29- }
3025 },
3126 methods: {
3227 handleScroll () {
3328 this .visible = window .pageYOffset > this .visibilityHeight
3429 },
3530 backToTop () {
36- if (this .isMoving ) return
37- const start = window .pageYOffset
38- let i = 0
39- this .isMoving = true
40- this .interval = setInterval (() => {
41- const next = Math .floor (this .easeInOutQuad (10 * i, start, - start, 500 ))
42- if (next <= 0 ) {
43- window .scrollTo (0 , 0 )
44- clearInterval (this .interval )
45- this .isMoving = false
46- } else {
47- window .scrollTo (0 , next)
48- }
49- i++
50- }, 16.7 )
51- },
52- easeInOutQuad (t , b , c , d ) {
53- if ((t /= d / 2 ) < 1 ) return c / 2 * t * t + b
54- return - c / 2 * (-- t * (t - 2 ) - 1 ) + b
31+ window .scrollTo (0 , 0 )
5532 }
5633 }
5734}
You can’t perform that action at this time.
0 commit comments