mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
042aecb7f6
no issue - minor reduction in build size. Before/after: - `vendor.min.js 3.32 MB (710.66 KB gzipped)` - `vendor.min.js 3.29 MB (706 KB gzipped)`
28 lines
759 B
JavaScript
28 lines
759 B
JavaScript
import Service from '@ember/service';
|
|
import erd from '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);
|
|
}
|
|
}
|
|
});
|