switch: allow resubmitting the same value

This commit is contained in:
jean-emmanuel 2024-02-21 11:01:50 +01:00
parent 3ed11f3894
commit e87891cb7c
2 changed files with 6 additions and 3 deletions

View file

@ -9,6 +9,7 @@
- widgets
- dropdown: allow resubmitting the same value
- switch: allow resubmitting the same value
- plot: missing `logScaleX` and `logScaleY` properties
- xy/multixy: add `axisLock` property; allow locking one the axis by holding `Shift` while dragging if `axisLock` is not set, bypasses it otherwise.
- knob/fader/range: add `colorKnob` property

View file

@ -57,7 +57,7 @@ class Switch extends MenuBase {
this.parseValues()
var dragCallback = (e, touchFix)=>{
var dragCallback = (e, slide)=>{
var index = 0,
node = e.target
@ -66,7 +66,7 @@ class Switch extends MenuBase {
node = e.firstTarget
}
if (touchFix && e.isTouch) {
if (slide && e.isTouch) {
// special traversing touch fix
node = document.elementFromPoint(e.clientX, e.clientY)
}
@ -81,7 +81,9 @@ class Switch extends MenuBase {
var value = this.values[index]
if (value !== this.value || this.value === undefined) this.setValue(value, {sync: true, send: true})
if (slide && value === this.value) return
this.setValue(value, {sync: true, send: true})
}