You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
470 B
20 lines
470 B
var Emitter = require('./Emitter');
|
|
|
|
exports = Emitter.extend({
|
|
className: 'MediaQuery',
|
|
initialize: function(query) {
|
|
var _this = this;
|
|
|
|
this.callSuper(Emitter, 'initialize');
|
|
this._mql = window.matchMedia(query);
|
|
|
|
this._mql.addListener(function() {
|
|
_this.emit(_this.isMatch() ? 'match' : 'unmatch');
|
|
});
|
|
},
|
|
isMatch: function() {
|
|
return this._mql.matches;
|
|
}
|
|
});
|
|
|
|
module.exports = exports;
|
|
|