MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getEdgeScrollDirections

Function getEdgeScrollDirections

src/cm/touchSelectionMenu.js:102–116  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

100 * @returns {{horizontal:number, vertical:number}}
101 */
102export function getEdgeScrollDirections(options) {
103 const { x, y, rect, allowHorizontal = true, gap = EDGE_SCROLL_GAP } = options;
104 let horizontal = 0;
105 let vertical = 0;
106
107 if (allowHorizontal) {
108 if (x < rect.left + gap) horizontal = -1;
109 else if (x > rect.right - gap) horizontal = 1;
110 }
111
112 if (y < rect.top + gap) vertical = -1;
113 else if (y > rect.bottom - gap) vertical = 1;
114
115 return { horizontal, vertical };
116}
117
118function clamp(value, min, max) {
119 return Math.max(min, Math.min(max, value));

Callers 1

runCodeMirrorTestsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected