MCPcopy Create free account
hub / github.com/ChartGPU/ChartGPU / toAnchor

Function toAnchor

src/interaction/createZoomState.ts:121–137  ·  view source on GitHub ↗
(nextStart: number, nextEnd: number, spec?: ZoomRangeAnchor)

Source from the content-addressed store, hash-verified

119 };
120
121 const toAnchor = (nextStart: number, nextEnd: number, spec?: ZoomRangeAnchor): { readonly center: number; readonly ratio: number } | undefined => {
122 if (!spec) return undefined;
123 if (typeof spec === 'string') {
124 switch (spec) {
125 case 'start':
126 return { center: nextStart, ratio: 0 };
127 case 'end':
128 return { center: nextEnd, ratio: 1 };
129 case 'center':
130 return { center: (nextStart + nextEnd) * 0.5, ratio: 0.5 };
131 }
132 }
133 if (spec && Number.isFinite(spec.center) && Number.isFinite(spec.ratio)) {
134 return { center: spec.center, ratio: spec.ratio };
135 }
136 return undefined;
137 };
138
139 const applyNextRange = (
140 nextStart: number,

Callers 2

setRangeAnchoredFunction · 0.85
setSpanConstraintsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected