# Coupling Sliders in GLMakie

**URL:** <https://discourse.julialang.org/t/coupling-sliders-in-glmakie/88130>\
**Category:** Visualization\
**Tags:** makie, glmakie\
**Created:** [October 2, 2022, 5:53pm UTC](https://discourse.julialang.org/t/coupling-sliders-in-glmakie/88130 "2022-10-02T17:53:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [October 2, 2022, 9:23pm UTC](https://discourse.julialang.org/t/coupling-sliders-in-glmakie/88130/4 "2022-10-02T21:23:35Z")

</div>

Essentially, you have the solution, and the only thing left is to break the circularity. This can be done by triggering a change only when slider state is out of the ‘good’ set of states. And to make sure the changes bring you back into the ‘good’ set of states (otherwise a “doom loop” can occur, like you suggested).

So for the example in the post:

```julia
using Observables

obs_func = on(slider1.value) do val
    abs(val+slider2.value[])>0.01 && Makie.set_close_to!(slider2, -val)
end

obs_func2 = on(slider2.value) do val
    abs(slider1.value[]+val)>0.01 && Makie.set_close_to!(slider1, -val)
end

```

The code makes sure `slider1` and `slider2` sum to zero.  
When I ran it, it worked quite smoothly.

---

_[View the full topic](https://discourse.julialang.org/t/coupling-sliders-in-glmakie/88130)._
