MCPcopy
hub / github.com/hundredrabbits/Left / animateScrollTo

Function animateScrollTo

desktop/sources/scripts/go.js:65–81  ·  view source on GitHub ↗
(element, to, duration)

Source from the content-addressed store, hash-verified

63 }
64
65 function animateScrollTo (element, to, duration) {
66 const start = element.scrollTop
67 const change = to - start
68 let currentTime = 0
69 const increment = 20 // Equal to line-height
70
71 const animate = function () {
72 currentTime += increment
73 const val = Math.easeInOutQuad(currentTime, start, change, duration)
74 element.scrollTop = val
75 if (!left.reader.active) left.stats.on_scroll()
76 if (currentTime < duration) {
77 requestAnimationFrame(animate, increment)
78 }
79 }
80 requestAnimationFrame(animate)
81 }
82
83 // t = current time
84 // b = start value

Callers 1

GoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected