Ghost/ghost/admin/app/services/resize-detector.js
Kevin Ansfield d95105b3a5 Remove usage of ember-element-resize-detector
no issue
- fixes babel deprecation warning coming from `ember-element-resize-detector`
- re-created basic `resize-detector` service to wrap `element-resize-detector`
    - import `element-resize-detector` directly from `npm` (includes bump to latest version)
    - drop usage of jQuery selectors
2018-04-30 17:03:29 +01:00

28 lines
763 B
JavaScript

import Service from '@ember/service';
import erd from 'npm:element-resize-detector';
export default Service.extend({
init() {
this._super(...arguments);
this.detector = erd({
strategy: 'scroll'
});
},
setup(selector, callback) {
let element = document.querySelector(selector);
if (!element) {
// eslint-disable-next-line
console.error(`service:resize-detector - could not find element matching ${selector}`);
}
this.detector.listenTo(element, callback);
},
teardown(selector, callback) {
let element = document.querySelector(selector);
if (element) {
this.detector.removeListener(element, callback);
}
}
});