Ghost/ghost/admin/app/routes/mobile-index-route.js

38 lines
957 B
JavaScript
Raw Normal View History

2015-02-13 07:22:32 +03:00
import Ember from 'ember';
2016-01-19 16:03:27 +03:00
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({
2016-01-19 16:03:27 +03:00
desktopTransition: K,
_callDesktopTransition: null,
2016-01-19 16:03:27 +03:00
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;
}
}
});