All files / src/lib subtitle-delay.ts

100% Statements 12/12
100% Branches 12/12
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21        1x 7x 7x 7x 2x 2x         1x 4x 4x 4x 1x 1x  
/**
 * Returns the delay step size (seconds) based on how long the button has been held.
 * elapsed is in milliseconds.
 */
export const getDelayStep = (elapsed: number): number => {
	if (elapsed >= 3000) return 5.0;
	if (elapsed >= 1500) return 1.0;
	if (elapsed >= 600) return 0.5;
	return 0.1;
};
 
/**
 * Returns the repeat interval (ms) for the hold-to-accelerate timer.
 */
export const getDelayInterval = (elapsed: number): number => {
	if (elapsed >= 3000) return 50;
	if (elapsed >= 1500) return 80;
	if (elapsed >= 600) return 120;
	return 200;
};