summaryrefslogtreecommitdiff
path: root/apps/web/src/timeline/snapping/threshold.ts
blob: f03111dc4ab189eddf9bffdcf17d5ab26eae7a8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { BASE_TIMELINE_PIXELS_PER_SECOND } from "@/timeline/scale";
import { TICKS_PER_SECOND } from "@/wasm";

const DEFAULT_TIMELINE_SNAP_THRESHOLD_PX = 10;

export function getTimelineSnapThresholdInTicks({
	zoomLevel,
	snapThresholdPx = DEFAULT_TIMELINE_SNAP_THRESHOLD_PX,
}: {
	zoomLevel: number;
	snapThresholdPx?: number;
}): number {
	const pixelsPerSecond = BASE_TIMELINE_PIXELS_PER_SECOND * zoomLevel;
	return (snapThresholdPx / pixelsPerSecond) * TICKS_PER_SECOND;
}