# Slider widget question: automatic moving slider is "jumping" when moved by mouse

**URL:** <https://discuss.streamlit.io/t/slider-widget-question-automatic-moving-slider-is-jumping-when-moved-by-mouse/113638>\
**Category:** Using Streamlit\
**Tags:** streamlit-elements, discussion\
**Created:** [May 28, 2025, 4:44am UTC](https://discuss.streamlit.io/t/slider-widget-question-automatic-moving-slider-is-jumping-when-moved-by-mouse/113638 "2025-05-28T04:44:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Horst](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/horst/32/63711_2.png) [@Horst](https://discuss.streamlit.io/u/Horst)\
**Post date:** [May 28, 2025, 4:44am UTC](https://discuss.streamlit.io/t/slider-widget-question-automatic-moving-slider-is-jumping-when-moved-by-mouse/113638/1 "2025-05-28T04:44:34Z")

</div>

I managed to find a python code where a slider widget is moved by code (increasing slider value every second). While it works (somewhat) the slider becomes is “jumping” when moved by the mouse, i need on average 2 times to put the slider to the new position where i want it to be, the slider tends to “jump” back to the original position, at least once.  
Is there a way for a cleaner code that allows an auto-advancing slider to still be set by the mouse ?  
Here is my code: (run locally)

```auto
import streamlit as st
import time

if 'slider_value' not in st.session_state:
    st.session_state['slider_value'] = 0

def update_value():
    if st.session_state['slider_value'] < 200:
        st.session_state['slider_value'] += 1

slider = st.slider('Set a value', 0, 200, st.session_state['slider_value'])

if slider != st.session_state['slider_value']:
    st.session_state['slider_value'] = slider

while st.session_state['slider_value'] < 200:
    time.sleep(1) # automatic increase every full second
    update_value()
    st.rerun()

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [November 24, 2025, 4:45am UTC](https://discuss.streamlit.io/t/slider-widget-question-automatic-moving-slider-is-jumping-when-moved-by-mouse/113638/2 "2025-11-24T04:45:28Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
