You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui/packages/consul-ui/app/helpers/dom-position.js

19 lines
523 B

import Helper from '@ember/component/helper';
export default class DomPosition extends Helper {
compute([target], { from }) {
if (typeof target === 'function') {
return entry => {
const $target = entry.target;
let rect = $target.getBoundingClientRect();
if (typeof from !== 'undefined') {
const fromRect = from.getBoundingClientRect();
rect.x = rect.x - fromRect.x;
rect.y = rect.y - fromRect.y;
}
return target(rect);
};
}
}
}