MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / binarySearchPosition

Method binarySearchPosition

src/utils/VirtualScroller.ts:230–246  ·  view source on GitHub ↗

* Binary search to find the index of the first item at or after the given scroll position

(scrollTop: number)

Source from the content-addressed store, hash-verified

228 * Binary search to find the index of the first item at or after the given scroll position
229 */
230 private binarySearchPosition(scrollTop: number): number {
231 if (this.positionCache.length === 0) return 0;
232
233 let left = 0;
234 let right = this.positionCache.length - 1;
235
236 while (left < right) {
237 const mid = Math.floor((left + right) / 2);
238 if (this.positionCache[mid] < scrollTop) {
239 left = mid + 1;
240 } else {
241 right = mid;
242 }
243 }
244
245 return Math.max(0, left - 1);
246 }
247
248 /**
249 * Get the height of an item (measured or estimated)

Callers 1

updateVisibleRangeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected