Skip to content

Commit 092ed36

Browse files
committed
Add the ability to set a presentation transition style
1 parent 5a57496 commit 092ed36

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def __init__(self, *args, **kwargs):
8484
# Requires self._* instead of self.__* for external class use
8585
self._language = "English"
8686
self._presentation_slides = {}
87+
self._presentation_transition = {}
8788
self._html_report_extra = [] # (Used by pytest_plugin.py)
8889
self._default_driver = None
8990
self._drivers_list = []
@@ -3209,7 +3210,8 @@ def add_meta_tag(self, http_equiv=None, content=None):
32093210

32103211
############
32113212

3212-
def create_presentation(self, name=None, theme="default"):
3213+
def create_presentation(
3214+
self, name=None, theme="default", transition="default"):
32133215
""" Creates a Reveal-JS presentation that you can add slides to.
32143216
@Params
32153217
name - If creating multiple presentations at the same time,
@@ -3218,6 +3220,9 @@ def create_presentation(self, name=None, theme="default"):
32183220
Valid themes: "serif" (default), "sky", "white", "black",
32193221
"simple", "league", "moon", "night",
32203222
"beige", "blood", and "solarized".
3223+
transition - Set a transition between slides.
3224+
Valid transitions: "none" (default), "slide", "fade",
3225+
"zoom", "convex", and "concave".
32213226
"""
32223227
if not name:
32233228
name = "default"
@@ -3230,6 +3235,15 @@ def create_presentation(self, name=None, theme="default"):
32303235
raise Exception(
32313236
"Theme {%s} not found! Valid themes: %s"
32323237
"" % (theme, valid_themes))
3238+
if not transition or transition == "default":
3239+
transition = "none"
3240+
valid_transitions = (
3241+
["none", "slide", "fade", "zoom", "convex", "concave"])
3242+
transition = transition.lower()
3243+
if transition not in valid_transitions:
3244+
raise Exception(
3245+
"Transition {%s} not found! Valid transitions: %s"
3246+
"" % (transition, valid_transitions))
32333247

32343248
reveal_theme_css = None
32353249
if theme == "serif":
@@ -3277,9 +3291,10 @@ def create_presentation(self, name=None, theme="default"):
32773291

32783292
self._presentation_slides[name] = []
32793293
self._presentation_slides[name].append(new_presentation)
3294+
self._presentation_transition[name] = transition
32803295

32813296
def add_slide(self, content=None, image=None, code=None, iframe=None,
3282-
content2=None, notes=None, name=None):
3297+
content2=None, notes=None, transition=None, name=None):
32833298
""" Allows the user to add slides to a presentation.
32843299
@Params
32853300
content - The HTML content to display on the presentation slide.
@@ -3290,6 +3305,9 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,
32903305
content2 - HTML content to display after adding an image or code.
32913306
notes - Additional notes to include with the slide.
32923307
ONLY SEEN if show_notes is set for the presentation.
3308+
transition - Set a transition between slides. (overrides previous)
3309+
Valid transitions: "none" (default), "slide", "fade",
3310+
"zoom", "convex", and "concave".
32933311
name - If creating multiple presentations at the same time,
32943312
use this to select the presentation to add slides to.
32953313
"""
@@ -3305,11 +3323,23 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,
33053323
content2 = ""
33063324
if not notes:
33073325
notes = ""
3308-
3326+
if not transition:
3327+
transition = self._presentation_transition[name]
3328+
elif transition == "default":
3329+
transition = "none"
3330+
valid_transitions = (
3331+
["none", "slide", "fade", "zoom", "convex", "concave"])
3332+
transition = transition.lower()
3333+
if transition not in valid_transitions:
3334+
raise Exception(
3335+
"Transition {%s} not found! Valid transitions: %s"
3336+
"" % (transition, valid_transitions))
33093337
add_line = ""
33103338
if content.startswith("<"):
33113339
add_line = "\n"
3312-
html = ('\n<section data-transition="none">%s%s' % (add_line, content))
3340+
html = (
3341+
'\n<section data-transition="%s">%s%s' % (
3342+
transition, add_line, content))
33133343
if image:
33143344
html += '\n<div flex_div><img rounded src="%s"></div>' % image
33153345
if code:

0 commit comments

Comments
 (0)