Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Therefore, we only document here the methods we think the end-user will ever use

```{eval-rst}
.. autoclass:: manim_slides.Slide
:members: start_loop, end_loop, pause, next_slide, wipe
:members: wait_time_between_slides, start_loop, end_loop, pause, next_slide, wipe

.. autoclass:: manim_slides.ThreeDSlide
:members:
Expand Down
59 changes: 59 additions & 0 deletions manim_slides/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
self.__current_animation = 0
self.__loop_start_animation: Optional[int] = None
self.__pause_start_animation = 0
self.__wait_time_between_slides = 0.0

@property
def __frame_height(self) -> float:
Expand Down Expand Up @@ -138,6 +139,61 @@ def __start_at_animation_number(self) -> Optional[int]:
else:
return config["from_animation_number"] # type: ignore

@property
def wait_time_between_slides(self) -> float:
"""
Returns the wait duration (in seconds) added between two slides.

By default, this value is set to 0.

Setting this value to something bigger than 0 will result in a
:code:`self.wait` animation called at the end of every slide.

..note::
This is useful because animations are usually only terminated
when a new animation is played. You can observe the small difference
in the examples below: the circle is not fully complete in the first
slide of the first example, but well in the second example.

Examples
--------

.. manim-slides:: WithoutWaitExample

from manim import *
from manim_slides import Slide

class WithoutWaitExample(Slide):
def construct(self):
circle = Circle(radius=2)

self.play(Create(circle))
self.next_slide()

self.play(FadeOut(circle))

.. manim-slides:: WithWaitExample

from manim import *
from manim_slides import Slide

class WithWaitExample(Slide):
def construct(self):
self.wait_time_between_slides = 0.1 # A small value > 1 / FPS
circle = Circle(radius=2)

self.play(Create(circle))
self.next_slide()

self.play(FadeOut(circle))

"""
return self.__wait_time_between_slides

@wait_time_between_slides.setter
def wait_time_between_slides(self, wait_time: float) -> None:
self.__wait_time_between_slides = max(wait_time, 0.0)

def play(self, *args: Any, **kwargs: Any) -> None:
"""Overloads `self.play` and increment animation count."""
super().play(*args, **kwargs)
Expand Down Expand Up @@ -187,6 +243,9 @@ def construct(self):
self.__loop_start_animation is None
), "You cannot call `self.next_slide()` inside a loop"

if self.wait_time_between_slides > 0.0:
self.wait(self.wait_time_between_slides)

self.__slides.append(
SlideConfig(
type=SlideType.slide,
Expand Down