Created
June 18, 2022 02:55
-
-
Save joehonton/8c688c27476ee3e7f1229db104eff7ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function computeLayout(idleDeadline) { | |
var milliseconds = idleDeadline.timeRemaining(); | |
var haltTime = performance.now() + milliseconds; | |
for (let i=lastIndex; i < queue.length; i++) { | |
if (performance.now() > haltTime) | |
break; | |
// pseudocode | |
x = R cosΦ sin(λ - λ₀) | |
y = R (cosΦ₀ sinΦ - sinΦ₀ cosΦ cos(λ - λ₀)) | |
lastIndex = i; | |
} | |
// if not complete, ask for another notification | |
if (lastIndex < queue.length-1) | |
idleCallbackId = requestIdleCallback(computeLayout); | |
else | |
idleCallbackId = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment