2015-02-13 05:22:32 +01:00
|
|
|
import Ember from 'ember';
|
2014-09-16 06:55:37 +02:00
|
|
|
|
2014-10-24 23:09:50 +02:00
|
|
|
// Routes that extend MobileIndexRoute need to implement
|
2014-09-16 06:55:37 +02:00
|
|
|
// desktopTransition, a function which is called when
|
|
|
|
// the user resizes to desktop levels.
|
2015-08-19 13:55:40 +02:00
|
|
|
export default Ember.Route.extend({
|
2014-09-16 06:55:37 +02:00
|
|
|
desktopTransition: Ember.K,
|
2015-11-20 18:26:34 +01:00
|
|
|
_callDesktopTransition: null,
|
2014-09-16 06:55:37 +02:00
|
|
|
|
2015-11-20 18:26:34 +01:00
|
|
|
mediaQueries: Ember.inject.service(),
|
2014-09-16 06:55:37 +02:00
|
|
|
|
2015-11-20 18:26:34 +01:00
|
|
|
activate: function () {
|
|
|
|
this._callDesktopTransition = () => {
|
|
|
|
if (!this.get('mediaQueries.isMobile')) {
|
|
|
|
this.desktopTransition();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Ember.addObserver(this, 'mediaQueries.isMobile', this._callDesktopTransition);
|
2014-09-16 06:55:37 +02:00
|
|
|
},
|
|
|
|
|
2015-11-20 18:26:34 +01:00
|
|
|
deactivate: function () {
|
|
|
|
if (this._callDesktopTransition) {
|
|
|
|
Ember.removeObserver(this, 'mediaQueries.isMobile', this._callDesktopTransition);
|
|
|
|
this._callDesktopTransition = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-16 06:55:37 +02:00
|
|
|
});
|