mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
577a749e12
no issue - followed the migration guide to switch to from lifecycle hooks to single `modify()` method - https://togithub.com/ember-modifier/ember-modifier/blob/master/MIGRATIONS.md - forced resolution of `ember-in-viewport@4.0.2` to avoid older version of `ember-modifier` being pulled in through `ember-infinity`
28 lines
686 B
JavaScript
28 lines
686 B
JavaScript
import Modifier from 'ember-modifier';
|
|
import {registerDestructor} from '@ember/destroyable';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class MovableModifier extends Modifier {
|
|
@service resizeDetector;
|
|
|
|
constructor(owner, args) {
|
|
super(owner, args);
|
|
registerDestructor(this, this.cleanup);
|
|
}
|
|
|
|
modify(element, [callback]) {
|
|
if (!this.didSetup) {
|
|
this.elem = element;
|
|
this.callback = callback;
|
|
|
|
this.resizeDetector.setup(element, callback);
|
|
|
|
this.didSetup = true;
|
|
}
|
|
}
|
|
|
|
cleanup = () => {
|
|
this.resizeDetector.teardown(this.elem, this.callback);
|
|
};
|
|
}
|