How to make the animation end immediately?

Hi there,

This my demo Gyasi’s Demo.

A few days ago, I used dcc.Interval to implement automatic updates according to documents and forums.

Then I have a question. When I toggle the switch to stop the automatic update, the animation will not end immediately, instead of the current animation actions will all play before stopping.

Cause I found that when my network condition is not good, it will continue to play multiple animations before stopping. I wanna try to optimize it.

So how can I make the animation end immediately?

The following is my code:

@app.callback(Output('interval-component', 'disabled'),
              [Input('toggle-switch', 'on'),
               Input('layout-0', 'hidden')])
def update_output(value, hidden):
    if hidden:
        return True
        return not value

                     'value'), [Input('interval-component', 'n_intervals')],
              [State('year-slider', 'value')])
def display_count_hidden(n, value):
    value = value or 0
    return (value + 1) % df.shape[0]
1 Like

Thanks to @Emil for giving me some reference solutions in another post. Then I found this, which solves the problem I mentioned in this old thread.

1 Like