MCPcopy
hub / github.com/callmecavs/jump.js / loop

Function loop

src/jump.js:40–59  ·  view source on GitHub ↗
(timeCurrent)

Source from the content-addressed store, hash-verified

38 // rAF loop helper
39
40 function loop (timeCurrent) {
41 // store time scroll started, if not started already
42 if (!timeStart) {
43 timeStart = timeCurrent
44 }
45
46 // determine time spent scrolling so far
47 timeElapsed = timeCurrent - timeStart
48
49 // calculate next scroll position
50 next = easing(timeElapsed, start, distance, duration)
51
52 // scroll to it
53 window.scrollTo(0, next)
54
55 // check progress
56 timeElapsed < duration
57 ? window.requestAnimationFrame(loop) // continue scroll loop
58 : done() // scrolling is done
59 }
60
61 // scroll finished helper
62

Callers

nothing calls this directly

Calls 1

doneFunction · 0.85

Tested by

no test coverage detected