UNPKG

infinite-scroll-svelte

Version:

Wrapper that fires events when the user has scrolled it to the beginning or end

17 lines (16 loc) 554 B
export class Throttle { throttleIntervalMs; nextThrottleTime; constructor(throttleIntervalMs, nextThrottleTime = performance.now()) { this.throttleIntervalMs = throttleIntervalMs; this.nextThrottleTime = nextThrottleTime; } get isThrottling() { const currentTime = performance.now(); const mustThrottle = currentTime < this.nextThrottleTime; if (mustThrottle === false) { this.nextThrottleTime = currentTime + this.throttleIntervalMs; } return mustThrottle; } }