UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

29 lines (28 loc) 694 B
import { __exports as element } from "../../../../../_virtual/element.mjs"; export { __exports as default } from "../../../../../_virtual/element.mjs"; Object.defineProperty(element, "__esModule", { value: true }); element.clientToElement = clientToElement; function clientToElement(x, y, elem) { var bounds = elem.getBoundingClientRect(); var pos = { x: 0, y: 0 }; if (x < bounds.left) { pos.x = 0; } else if (x >= bounds.right) { pos.x = bounds.width - 1; } else { pos.x = x - bounds.left; } if (y < bounds.top) { pos.y = 0; } else if (y >= bounds.bottom) { pos.y = bounds.height - 1; } else { pos.y = y - bounds.top; } return pos; }