accounts: infinite scroll for performance
Found out the bottleneck when ~2000 or more elements are loaded isn't the search or sort or anything, but the DOM. An infinite scroll implementation is added, where elements are added to the DOM as you scroll. May still be a little buggy, and can't yet cope with screen resizes. Also, the "shown" indicator is broken.
This commit is contained in:
@@ -306,3 +306,20 @@ export function unicodeB64Encode(s: string): string {
|
||||
const bin = String.fromCodePoint(...encoded);
|
||||
return btoa(bin);
|
||||
}
|
||||
|
||||
// Only allow running a function every n milliseconds.
|
||||
// Source: Clément Prévost at https://stackoverflow.com/questions/27078285/simple-throttle-in-javascript
|
||||
// function foo<T>(bar: T): T {
|
||||
export function throttle (callback: () => void, limitMilliseconds: number): () => void {
|
||||
var waiting = false; // Initially, we're not waiting
|
||||
return function () { // We return a throttled function
|
||||
if (!waiting) { // If we're not waiting
|
||||
callback.apply(this, arguments); // Execute users function
|
||||
waiting = true; // Prevent future invocations
|
||||
setTimeout(function () { // After a period of time
|
||||
waiting = false; // And allow future invocations
|
||||
}, limitMilliseconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user