Skip to content

Commit 2457ca8

Browse files
fix(cli): properly rewind / previous slide after reverse (#28)
* fix(cli): properly rewind / previous slide after reverse Closes #24 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9900b31 commit 2457ca8

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

docs/source/conf.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9-
project = 'Manim Slides'
10-
copyright = '2022, Jérome Eertmans'
11-
author = 'Jérome Eertmans'
9+
project = "Manim Slides"
10+
copyright = "2022, Jérome Eertmans"
11+
author = "Jérome Eertmans"
1212

1313
# -- General configuration ---------------------------------------------------
1414
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1515

1616
extensions = ["sphinx.ext.autodoc", "sphinx_click"]
1717

18-
templates_path = ['_templates']
18+
templates_path = ["_templates"]
1919
exclude_patterns = []
2020

2121

22-
2322
# -- Options for HTML output -------------------------------------------------
2423
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
2524

26-
html_theme = 'furo'
27-
html_static_path = ['_static']
25+
html_theme = "furo"
26+
html_static_path = ["_static"]

manim_slides/present.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ def rewind_current_slide(self):
134134

135135
self.current_cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
136136

137+
def cancel_reverse(self):
138+
"""Cancels any effet produced by a reversed slide."""
139+
if self.reverse:
140+
self.reverse = False
141+
self.reversed_animation = -1
142+
self.release_cap()
143+
137144
def reverse_current_slide(self):
138145
"""Reverses current slide."""
139146
self.reverse = True
@@ -142,9 +149,7 @@ def reverse_current_slide(self):
142149
def load_next_slide(self):
143150
"""Loads next slide."""
144151
if self.reverse:
145-
self.reverse = False
146-
self.reversed_animation = -1
147-
self.release_cap()
152+
self.cancel_reverse()
148153
self.rewind_current_slide()
149154
elif self.current_slide.is_last():
150155
self.current_slide.terminated = True
@@ -156,6 +161,7 @@ def load_next_slide(self):
156161

157162
def load_previous_slide(self):
158163
"""Loads previous slide."""
164+
self.cancel_reverse()
159165
self.current_slide_index = max(0, self.current_slide_index - 1)
160166
self.rewind_current_slide()
161167

@@ -425,7 +431,7 @@ def handle_key(self):
425431
elif self.config.BACK.match(key):
426432
if self.current_presentation.current_slide_index == 0:
427433
if self.current_presentation_index == 0:
428-
self.current_presentation.rewind_current_slide()
434+
self.current_presentation.load_previous_slide()
429435
else:
430436
self.current_presentation_index -= 1
431437
self.current_presentation.load_last_slide()
@@ -437,6 +443,7 @@ def handle_key(self):
437443
self.current_presentation.reverse_current_slide()
438444
self.state = State.PLAYING
439445
elif self.config.REWIND.match(key):
446+
self.current_presentation.cancel_reverse()
440447
self.current_presentation.rewind_current_slide()
441448
self.state = State.PLAYING
442449

0 commit comments

Comments
 (0)