@platformos/pos-cli
Version:
Manage your platformOS application
32 lines (27 loc) • 638 B
JavaScript
/**
* Copyright (c) 2019 GraphQL Contributors.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Utility functions to get a pixel distance from left/top of the window.
*/
export function getLeft(initialElem) {
let pt = 0;
let elem = initialElem;
while (elem.offsetParent) {
pt += elem.offsetLeft;
elem = elem.offsetParent;
}
return pt;
}
export function getTop(initialElem) {
let pt = 0;
let elem = initialElem;
while (elem.offsetParent) {
pt += elem.offsetTop;
elem = elem.offsetParent;
}
return pt;
}