"use strict"; import {EventModel} from "./EventModel.ecma.js"; import {Utils} from "../Utils/Utils.ecma.js"; /** * @class * @constructor * @param {!(string|HTMLElement)} selector * @returns {void} * @access public * @static */ export const ScreenModel = (function(){ /** * @constructs ScreenModel * @param {!(string|HTMLElement)} selector * @returns {void} * @access private * @static */ const ScreenModel = function(selector){ /** @type {ScreenModel} */ const self = this; /** @type {number|null} */ let interval = null; /** @type {number} */ this.x = 0; /** @type {number} */ this.y = 0; /** @type {HTMLElement|null} */ this.item = null; /** @type {EventModel} */ this.on_change = new EventModel(); /** * @returns {void} * @access private */ const constructor = () => { Utils.preload(selector, (item, asynchronous, ok) => { if(ok){ self.item = item; interval = setInterval(() => { if(self.x != self.item.offsetWidth || self.y != self.item.offsetHeight){ self.x = self.item.offsetWidth; self.y = self.item.offsetHeight; this.on_change.execute(self.x, self.y, self.item); }; }, 100); }; }); }; constructor(); }; return ScreenModel; })();