UNPKG

@dooboostore/dom-render

Version:
102 lines 3.35 kB
import { ComponentBase } from '../ComponentBase'; import { DomRender } from '../../DomRender'; import { RawSet } from '../../rawsets/RawSet'; export var Timer; (function (Timer_1) { Timer_1.selector = 'dr-timer'; // class RadioBase extends ComponentBase<Attribute> { // public hidden = true; // // } // @Component({ // template: '<div dr-if="!@this@.hidden" dr-strip="true">#innerHTML#</div>', // styles: '', // selector: `${selector}.Checked` // }) // export class RadioChecked extends RadioBase { // public name = 'Checked'; // // constructor() { // super({ onlyParentType: Radio }); // } // } // // @Component({ // template: '<div dr-if="!@this@.hidden" dr-strip="true">#innerHTML#</div>', // styles: '', // selector: `${selector}.UnChecked` // }) // export class UnChecked extends RadioBase { // public name = 'unChecked'; // // constructor() { // super({ onlyParentType: Radio }); // } // } // @Component({ // template: '#innerHTML#', // selector: `${selector}`, // noStrip: true // }) class Timer extends ComponentBase { onInitRender(param, rawSet) { var _a; super.onInitRender(param, rawSet); console.log('---2', (_a = this.getElement()) === null || _a === void 0 ? void 0 : _a.isConnected); // const element = this.getElement(); // if(element){ // (element as any).component = this; // } } isRunning() { return this.timeSecond !== undefined; } start() { const timeSecond = this.getAttribute('timeSecond'); if (timeSecond) { this.timeSecond = parseInt(timeSecond); this.interval = setInterval(() => { // console.log('--------->',this.timeSecond) if (this.timeSecond) { this.timeSecond--; } else { clearInterval(this.interval); this.timeSecond = undefined; this.interval = undefined; } }, 1000); } } stop() { if (this.interval) { clearInterval(this.interval); this.interval = undefined; this.timeSecond = undefined; } } onChangeAttrRender(name, val, other) { super.onChangeAttrRender(name, val, other); console.log('-----', name, val, this.getElement()); } onDestroyRender(data) { super.onDestroyRender(data); if (this.interval) { clearInterval(this.interval); } } } Timer_1.Timer = Timer; })(Timer || (Timer = {})); export default { choose: (config) => { return RawSet.createComponentTargetElement({ name: `${Timer.selector}`, template: '#innerHTML#', objFactory: (e, o, r2, counstructorParam) => { return DomRender.run({ rootObject: new Timer.Timer(...counstructorParam), config: config }); } }); }, }; //# sourceMappingURL=Timer.js.map