elmer-ui-core
Version:
web app framework
49 lines (48 loc) • 2.08 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.WindowResizeListen = void 0;
var elmer_common_1 = require("elmer-common");
var WindowResizeListen = (function (_super) {
__extends(WindowResizeListen, _super);
function WindowResizeListen() {
return _super !== null && _super.apply(this, arguments) || this;
}
WindowResizeListen.prototype.listen = function () {
window.onresize = this.handleOnResize.bind(this);
};
WindowResizeListen.prototype.handleOnResize = function () {
var _this = this;
var liseners = this.getEventListener();
var width = window.innerWidth, height = window.innerHeight;
Object.keys(liseners).map(function (callBackKey) {
var callBack = liseners[callBackKey];
_this.isFunction(callBack) && callBack(width, height);
});
};
WindowResizeListen.prototype.getEventListener = function () {
var listeners = elmerData.resizeListeners || {};
return listeners || {};
};
WindowResizeListen.prototype.remove = function (id) {
if (elmerData.resizeListeners) {
delete elmerData.resizeListeners[id];
}
};
return WindowResizeListen;
}(elmer_common_1.Common));
exports.WindowResizeListen = WindowResizeListen;