SPB Git forge

spb/admin-ka

Public
41commits 1branches 0releases
172.9 MBsize
maindefault branch
19 days agolast push
JavaScript 65.5% Python 17.8% CSS 13% HTML 3.7%
804 B · 41 lines javascript
Raw Blame History
1"use strict";23Object.defineProperty(exports, "__esModule", {4  value: true5});6exports.clientToElement = clientToElement;7/*8 * noVNC: HTML5 VNC client9 * Copyright (C) 2020 The noVNC authors10 * Licensed under MPL 2.0 (see LICENSE.txt)11 *12 * See README.md for usage and integration instructions.13 */1415/*16 * HTML element utility functions17 */1819function clientToElement(x, y, elem) {20  var bounds = elem.getBoundingClientRect();21  var pos = {22    x: 0,23    y: 024  };25  // Clip to target bounds26  if (x < bounds.left) {27    pos.x = 0;28  } else if (x >= bounds.right) {29    pos.x = bounds.width - 1;30  } else {31    pos.x = x - bounds.left;32  }33  if (y < bounds.top) {34    pos.y = 0;35  } else if (y >= bounds.bottom) {36    pos.y = bounds.height - 1;37  } else {38    pos.y = y - bounds.top;39  }40  return pos;41}