MCPcopy Create free account
hub / github.com/editablejs/editable / linearScale

Function linearScale

packages/ui/src/scroll-area.tsx:1018–1024  ·  view source on GitHub ↗
(input: readonly [number, number], output: readonly [number, number])

Source from the content-addressed store, hash-verified

1016
1017// https://github.com/tmcw-up-for-adoption/simple-linear-scale/blob/master/index.js
1018function linearScale(input: readonly [number, number], output: readonly [number, number]) {
1019 return (value: number) => {
1020 if (input[0] === input[1] || output[0] === output[1]) return output[0]
1021 const ratio = (output[1] - output[0]) / (input[1] - input[0])
1022 return output[0] + ratio * (value - input[0])
1023 }
1024}
1025
1026function isScrollingWithinScrollbarBounds(scrollPos: number, maxScrollPos: number) {
1027 return scrollPos > 0 && scrollPos < maxScrollPos

Callers 2

getThumbOffsetFromScrollFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…