MCPcopy Create free account
hub / github.com/apache/cloudstack / clientToElement

Function clientToElement

systemvm/agent/noVNC/core/util/element.js:13–32  ·  view source on GitHub ↗
(x, y, elem)

Source from the content-addressed store, hash-verified

11 */
12
13export function clientToElement(x, y, elem) {
14 const bounds = elem.getBoundingClientRect();
15 let pos = { x: 0, y: 0 };
16 // Clip to target bounds
17 if (x < bounds.left) {
18 pos.x = 0;
19 } else if (x >= bounds.right) {
20 pos.x = bounds.width - 1;
21 } else {
22 pos.x = x - bounds.left;
23 }
24 if (y < bounds.top) {
25 pos.y = 0;
26 } else if (y >= bounds.bottom) {
27 pos.y = bounds.height - 1;
28 } else {
29 pos.y = y - bounds.top;
30 }
31 return pos;
32}

Callers 4

_handleMouseMethod · 0.90
_handleWheelMethod · 0.90
_handleTapEventMethod · 0.90
_handleGestureMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected