led: simplify

This commit is contained in:
jean-emmanuel 2017-06-22 09:15:57 +02:00
parent 00dc551eea
commit 94864ac551
3 changed files with 16 additions and 30 deletions

View file

@ -40,14 +40,11 @@ module.exports = class Led extends _widgets_base {
var html = `
<div class="led">
<div><span></span></div>
</div>
`
super({...options, html: html})
this.led = this.widget.find('span')
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
this.setValue(this.getProp('range').min)
@ -77,7 +74,7 @@ module.exports = class Led extends _widgets_base {
setValue(v) {
if (typeof v != 'number') return
this.led.css('opacity',mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
this.widget[0].style.setProperty('--opacity', mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
}

View file

@ -38,14 +38,11 @@ module.exports = class Led extends _widgets_base {
var html = `
<div class="led">
<div><span></span></div>
</div>
`
super({...options, html: html})
this.led = this.widget.find('span')
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
this.setValue([0,0,0,0])
@ -84,7 +81,7 @@ module.exports = class Led extends _widgets_base {
v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1])
this.led[0].style.setProperty('--color-custom',`rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})`)
this.widget[0].style.setProperty('--color-custom',`rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})`)
}