2019-12-17 19:27:28 +00:00
|
|
|
import Helper from '@ember/component/helper';
|
2020-12-08 09:27:28 +00:00
|
|
|
|
|
|
|
export default class DomPosition extends Helper {
|
2020-12-11 09:38:33 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
}
|
2020-12-08 09:27:28 +00:00
|
|
|
}
|
|
|
|
}
|