John Cowen a66973a274 ui: Native-ize class based helpers (#9337)
* Install ember-decorators/observes

* Remove filter-predicate

* Nativize `env` and inject env service

* Nativize all other class based helpers
2020-12-08 09:27:59 +00:00

17 lines
488 B
JavaScript

import Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
export default class DomPosition extends Helper {
@service('dom') dom;
compute([target, from], hash) {
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;
}
}