(options)
| 100 | * @returns {{horizontal:number, vertical:number}} |
| 101 | */ |
| 102 | export 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 | |
| 118 | function clamp(value, min, max) { |
| 119 | return Math.max(min, Math.min(max, value)); |
no outgoing calls
no test coverage detected