molstar
Version:
A comprehensive macromolecular library.
27 lines • 874 B
JavaScript
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.eventOffset = void 0;
var rootPosition = { left: 0, top: 0 };
function eventOffset(out, ev, target) {
var cx = ev.clientX || 0;
var cy = ev.clientY || 0;
var rect = getBoundingClientOffset(target);
out[0] = cx - rect.left;
out[1] = cy - rect.top;
return out;
}
exports.eventOffset = eventOffset;
function getBoundingClientOffset(element) {
if (element instanceof Window || element instanceof Document || element === document.body) {
return rootPosition;
}
else {
return element.getBoundingClientRect();
}
}
//# sourceMappingURL=event-offset.js.map
;