Skip to content

Commit 2bed49c

Browse files
committed
Add reverse play button and forward/reverse looping
1 parent 82fd4ac commit 2bed49c

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

src/e3sm_quickview/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(self, server=None):
5656
"trame__favicon": ASSETS.icon,
5757
"is_tauri": False,
5858
"animation_play": False,
59+
"animation_direction": "forward",
5960
# All available variables
6061
"variables_listing": [],
6162
# Selected variables to load

src/e3sm_quickview/components/toolbars.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,25 @@ def __init__(self):
482482
)
483483
v3.VDivider(vertical=True, classes="mx-2")
484484
v3.VIconBtn(
485-
icon=("animation_play ? 'mdi-stop' : 'mdi-play'",),
485+
icon=(
486+
"animation_play && animation_direction === 'reverse' ? 'mdi-stop' : 'mdi-play'",
487+
),
486488
flat=True,
487-
click="animation_play = !animation_play",
488-
disabled=("capture_recording",),
489+
click="if (animation_play && animation_direction === 'reverse') { animation_play = false } else { animation_direction = 'reverse'; animation_play = true }",
490+
disabled=(
491+
"capture_recording || (animation_play && animation_direction === 'forward')",
492+
),
493+
style="transform: scaleX(-1);",
494+
)
495+
v3.VIconBtn(
496+
icon=(
497+
"animation_play && animation_direction === 'forward' ? 'mdi-stop' : 'mdi-play'",
498+
),
499+
flat=True,
500+
click="if (animation_play && animation_direction === 'forward') { animation_play = false } else { animation_direction = 'forward'; animation_play = true }",
501+
disabled=(
502+
"capture_recording || (animation_play && animation_direction === 'reverse')",
503+
),
489504
)
490505
v3.VDivider(vertical=True, classes="mx-2")
491506

@@ -572,7 +587,13 @@ async def _run_animation(self):
572587
with self.state as s:
573588
while s.animation_play:
574589
await asyncio.sleep(0.1)
575-
if s.animation_step < s.animation_step_max:
576-
await self._step_to(s.animation_step + 1)
590+
if s.animation_direction == "reverse":
591+
if s.animation_step > 0:
592+
await self._step_to(s.animation_step - 1)
593+
else:
594+
await self._step_to(s.animation_step_max)
577595
else:
578-
s.animation_play = False
596+
if s.animation_step < s.animation_step_max:
597+
await self._step_to(s.animation_step + 1)
598+
else:
599+
await self._step_to(0)

0 commit comments

Comments
 (0)