"snap" function like touchable (spring?)

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?

You can make the faders’ spring property depend on that button’s value:

JS{{
// spring property
return @{button_id}
}}

that one worked, I’m @ 50% now.

problem is the faders reset to 0 on release, it needs to reset to the value the fader was at the moment the button was pressed.

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.

  1. the spring property is set as said above
  2. the default property retreives a global variable stored by the script widget
  3. 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.

global_spring.json (4.5 KB)

1 Like

amazing! thank you so much for this :smiling_face_with_three_hearts:

implemented and works how expected, it has a little loading time but
as announced, that will probably go away.

It should be fixed in v0.47.0 !

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)
    JS{{
      global.faderValues = global.faderValues || {}
    }}
1 Like

it works perfect now :sunglasses: