class EFMarquee { constructor() { this.element = null; } static getInstance() { return (typeof yunos != 'undefined') ? tv_marquee : new EFMarquee(); } create(node, speed) { this.element = node; this.timer = null; this.startX = 0; this.stopX = 0; this.currentX = 0; return this; } start(circle) { // this.element.className = 'ef_marquee'; this.element.classList.add('ef_marquee'); console.log('document :' + document.body.clientWidth); console.log('marquee p width:' + this.element.childNodes[0].clientWidth); this.startX = this.element.clientWidth; this.stopX = this.element.childNodes[0].clientWidth * -1; this.currentX = this.startX; function updateFrame(dom, x) { dom.setAttribute('style', 'left:' + x + 'px'); } function update(context) { context.timer = setTimeout(function() { context.currentX -= 1; updateFrame(context.element.childNodes[0], context.currentX); if (context.currentX > context.stopX) { update(context); return; } if (circle) { context.currentX = context.startX; update(context); } else { context.currentX = 0; updateFrame(context.element.childNodes[0], context.currentX); } }.bind(this), 30); } update(this); } setStr(str) { this.element.innerHTML = '
' + str + '
'; } stop() { this.element.className = ''; clearTimeout(this.timer); } } module.exports = EFMarquee;