Skip to content

Commit ed30e21

Browse files
authored
Add Feature BackgroundSize (#132)
1 parent a9f5355 commit ed30e21

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

manim_slides/convert.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ class TransitionSpeed(Str, Enum): # type: ignore
170170
slow = "slow"
171171

172172

173+
class BackgroundSize(Str, Enum): # type: ignore
174+
# From: https://developer.mozilla.org/en-US/docs/Web/CSS/background-size
175+
# TODO: support more background size
176+
contain = "contain"
177+
cover = "cover"
178+
179+
173180
BackgroundTransition = Transition
174181

175182

@@ -258,6 +265,7 @@ class RevealJS(Converter):
258265
focus_body_on_page_visibility_change: JsBool = JsBool.true
259266
transition: Transition = Transition.none
260267
transition_speed: TransitionSpeed = TransitionSpeed.default
268+
background_size: BackgroundSize = BackgroundSize.contain # Not in RevealJS
261269
background_transition: BackgroundTransition = BackgroundTransition.none
262270
pdf_max_pages_per_slide: Union[int, str] = "Number.POSITIVE_INFINITY"
263271
pdf_separate_fragments: JsBool = JsBool.true
@@ -291,9 +299,9 @@ def get_sections_iter(self) -> Generator[str, None, None]:
291299
# Read more about this:
292300
# https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide#autoplay_and_autoplay_blocking
293301
if slide_config.is_loop():
294-
yield f'<section data-background-video="{file}" data-background-video-muted data-background-video-loop></section>'
302+
yield f'<section data-background-size={self.background_size.value} data-background-video="{file}" data-background-video-muted data-background-video-loop></section>'
295303
else:
296-
yield f'<section data-background-video="{file}" data-background-video-muted></section>'
304+
yield f'<section data-background-size={self.background_size.value} data-background-video="{file}" data-background-video-muted></section>'
297305

298306
def load_template(self) -> str:
299307
"""Returns the RevealJS HTML template as a string."""

0 commit comments

Comments
 (0)