crossfader: fix value parsing (correctly interpret incomming osc and value from the slider)

This commit is contained in:
jean-emmanuel 2017-01-03 15:55:06 +01:00
parent e5af6f7d96
commit 399c66fe1a

View file

@ -32,13 +32,7 @@ module.exports = class Crossfader extends Switcher {
e.stopPropagation()
if (this.fader.value == 0) {
this.setValue('A', e.options)
} else if (this.fader.value == 1) {
this.setValue('B', e.options)
} else {
this.setValue(this.fader.getValue(), e.options)
}
this.setValue(this.fader.getValue(), e.options)
})
@ -46,7 +40,13 @@ module.exports = class Crossfader extends Switcher {
setValue(v, options={}) {
super.setValue(...arguments)
var v = v <= 0 || v == 'A' ?
'A' :
v >= 1 || v == 'B' ?
'B' :
v
super.setValue(v, options)
if (typeof v == 'object') {
@ -54,20 +54,20 @@ module.exports = class Crossfader extends Switcher {
}
if (v == 'A' || v <= 0) {
if (v == 'A') {
this.fader.setValue(0, {dragged:options.dragged})
this.value._fader = 0
} else if (v == 'B' || v >= 1) {
} else if (v == 'B') {
this.fader.setValue(1, {dragged:options.dragged})
this.value._fader = 1
} else if (!isNaN(v)) {
this.fader.setValue(v, {dragged:options.dragged})
this.value._fader = this.fader.getValue()
this.value._selected = false