Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for slide effect #8

Merged
merged 2 commits into from Oct 23, 2022
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MkDocs GLightbox
# MkDocs GLightbox

[![PyPI version](https://img.shields.io/pypi/v/mkdocs-glightbox.svg)](https://pypi.org/project/mkdocs-glightbox)
[![PyPI downloads](https://img.shields.io/pypi/dm/mkdocs-glightbox.svg)](https://pypi.org/project/mkdocs-glightbox)
Expand Down Expand Up @@ -39,11 +39,12 @@ GLightbox is a pure javascript lightbox library with mobile support.
touchNavigation: true
loop: false
effect: zoom
slide_effect: slide
width: 100%
height: auto
zoomable: true
draggable: true
skip_classes:
skip_classes:
- custom-skip-class-name
auto_caption: false
caption_position: bottom
Expand All @@ -54,6 +55,7 @@ GLightbox is a pure javascript lightbox library with mobile support.
| touchNavigation | true | Enable or disable the touch navigation (swipe). |
| loop | false | Loop slides on end. |
| effect | zoom | Name of the effect on lightbox open. (zoom, fade, none) |
| slide_effect | slide | Name of the effect on lightbox slide. (slide, zoom, fade, none) |
| width | 100% | Width for inline elements and iframes. You can use any unit for example 90% or 100vw for full width. |
| height | auto | Height for inline elements and iframes. You can use any unit for example 90%, 100vh or auto. |
| zoomable | true | Enable or disable zoomable images. |
Expand Down
3 changes: 3 additions & 0 deletions mkdocs_glightbox/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class LightboxPlugin(BasePlugin):
("loop", config_options.Type(bool, default=False)),
("effect",
config_options.Choice(("zoom", "fade", "none"), default="zoom")),
("slide_effect",
config_options.Choice(("slide", "zoom", "fade", "none"), default="slide")),
("width", config_options.Type(str, default="100%")),
("height", config_options.Type(str, default="auto")),
("zoomable", config_options.Type(bool, default=True)),
Expand Down Expand Up @@ -71,6 +73,7 @@ def on_post_page(self, output, page, config, **kwargs):
}
lb_config['openEffect'] = plugin_config.get('effect', 'zoom')
lb_config['closeEffect'] = plugin_config.get('effect', 'zoom')
lb_config['slideEffect'] = plugin_config.get('slide_effect', 'slide')
js_code.string = f"const lightbox = GLightbox({json.dumps(lb_config)});"
if config[
"theme"].name == "material" or "navigation.instant" in config[
Expand Down