2019-12-17 19:27:28 +00:00
|
|
|
import Helper from '@ember/component/helper';
|
|
|
|
import { inject as service } from '@ember/service';
|
2020-12-08 09:27:28 +00:00
|
|
|
|
|
|
|
export default class DomPosition extends Helper {
|
|
|
|
@service('dom') dom;
|
|
|
|
|
|
|
|
compute([target, from], hash) {
|
2020-11-30 16:52:13 +00:00
|
|
|
const $target = this.dom.element(target);
|
|
|
|
const $from = this.dom.element(from);
|
|
|
|
const fromRect = $from.getBoundingClientRect();
|
|
|
|
const rect = $target.getBoundingClientRect();
|
|
|
|
rect.x = rect.x - fromRect.x;
|
|
|
|
rect.y = rect.y - fromRect.y;
|
|
|
|
return rect;
|
2020-12-08 09:27:28 +00:00
|
|
|
}
|
|
|
|
}
|