Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
var Emitter = require('./Emitter');
exports = Emitter.extend({
className: 'MediaQuery',
initialize: function(query) {
var _this = this;
this.callSuper(Emitter, 'initialize');
this._listener = function() {
_this.emit(_this.isMatch() ? 'match' : 'unmatch');
};
this.setQuery(query);
},
setQuery: function(query) {
if (this._mql) {
this._mql.removeListener(this._listener);
}
this._mql = window.matchMedia(query);
this._mql.addListener(this._listener);
},
isMatch: function() {
return this._mql.matches;
}
});
module.exports = exports;