Hello, i would like to have a “snap” function like touchable has, shown here :
for example i have 16 Faders that control synth Parameters in Ableton.
if the snapButton is activated, all parameters will reset to current value on Fader release,
just how the “spring” property works.
basically a button that turns spring to “true” and sets the new “default” values of all 16 sliders.
or did i misunderstood the “spring” thing?
Here is a minimal example solving this problem with a script widget (see attached session file). You need the latest release (v0.46.2) to make it work.
the spring property is set as said above
the default property retreives a global variable stored by the script widget
the script widget is linked to the toggle and stores the faders’ values when the it is toggled to 1
It’s a bit hacky but seems to do the job. The main caveat is that the spring and default properties are not dynamic and trigger a rebuild of the widget when they change, it should be fixed in the next release.
unfortunately its no longer working with v0.47.0 !
i cannot move the faders at all, everytime i try i get this errors in the console:
[Renderer process error]
Uncaught TypeError: Cannot read property ‘toFixed’ of undefined
at setValue (src/client/app/widgets/sliders/slider.js:234:65)
at dragHandle (src/client/app/widgets/sliders/fader.js:165:13)
at dragHandleProxy (src/client/app/widgets/sliders/slider.js:134:8)
at this._listeners[evt].slice (src/client/app/events/event-emitter.js:29:29)
at triggerWidgetEvent (src/client/app/events/drag.js:194:28)
at event.traversingContainer.contains (src/client/app/events/drag.js:72:8)
at pointerMoveFilter (src/client/app/events/drag.js:96:27)
at mouseMoveCapture (src/client/app/events/drag.js:126:4)
Ah, that’s a litle side effect… the default property does not resolve properly at loading time because the global variable is initialized after the faders are created, you can fix it either by:
putting the script widget before the faders in the parent widget’s children list
adding a fallback line in the fader’s default property before the return statement if (!global.faderValues) return 0
declaring the global variable in any of the root widget’s properties (that will ensure it’s declared before any other widget is created)