I’d like for a Lottie Animation Loop to switch to True when a dbc.Button (containing the Lottie) is hovered over and switch back to False when the cursor is off the lottie/button. I have set hoverData to button id and lottie id but it is not animating. What is a good way to capture the hover-off action? This probably makes it two questions in one, sorry…
Lottie
settings_lottie_url = 'https://assets9.lottiefiles.com/packages/lf20_zp7xw196.json'
options = dict(loop=False, autoplay=True, rendererSettings=dict(preserveAspectRatio='xMidYMid slice'))
settings_lottie = de.Lottie(options=options, width="2rem", height="2rem", url=settings_lottie_url, id='update_lottie_activity')
Button Setup
user_timeline_options_btn = dbc.Button(settings_lottie,
id="open-activity_options",
n_clicks=0,color='primary',
className="ml-auto btn btn-outline-light",
style={
'margin-left':'50px',
'border-radius': '5px',
'border': 'none',
'padding': '2px'}
)
Callback
@app.callback(
Output('update_lottie_activity', 'options'),
Input('open-activity_options', 'hoverData')
)
def hover_user_activity_lottie(hoverData):
print(hoverData)
if hoverData:
return dict(loop=True, autoplay=True, rendererSettings=dict(preserveAspectRatio='xMidYMid slice'))
else:
return dict(loop=False, autoplay=True, rendererSettings=dict(preserveAspectRatio='xMidYMid slice'))