Ghost/ghost/admin/app/routes/mobile-index-route.js
2016-01-19 07:03:27 -06:00

38 lines
957 B
JavaScript

import Ember from 'ember';
const {
Route,
addObserver,
inject: {service},
removeObserver,
K
} = Ember;
// Routes that extend MobileIndexRoute need to implement
// desktopTransition, a function which is called when
// the user resizes to desktop levels.
export default Route.extend({
desktopTransition: K,
_callDesktopTransition: null,
mediaQueries: service(),
activate() {
this._super(...arguments);
this._callDesktopTransition = () => {
if (!this.get('mediaQueries.isMobile')) {
this.desktopTransition();
}
};
addObserver(this, 'mediaQueries.isMobile', this._callDesktopTransition);
},
deactivate() {
this._super(...arguments);
if (this._callDesktopTransition) {
removeObserver(this, 'mediaQueries.isMobile', this._callDesktopTransition);
this._callDesktopTransition = null;
}
}
});