Skip to content

Commit f0420bd

Browse files
committed
Fix some options not working bug
1 parent 87f3905 commit f0420bd

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
mkdocs-glightbox-0.1.6 (2022-07-16)
2+
3+
* Fix some options not working bug
4+
15
mkdocs-glightbox-0.1.5 (2022-07-16)
26

37
* Fix mkdocs-material header + sidebar vanishing issue when open lightbox (Inspired from https://github.com/biati-digital/glightbox/issues/22)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
A MkDocs plugin supports image lightbox with [GLightbox](https://github.com/biati-digital/glightbox).
77

8-
GLightbox is pure Javascript lightbox library with mobile support.
8+
GLightbox is a pure javascript lightbox library with mobile support.
99

1010
[Live demo](https://blueswen.github.io/mkdocs-glightbox/) with [mkdocs-material](https://squidfunk.github.io/mkdocs-material/) theme.
1111

@@ -36,7 +36,7 @@ GLightbox is pure Javascript lightbox library with mobile support.
3636
```yaml
3737
plugins:
3838
- glightbox:
39-
touchNavigation: false
39+
touchNavigation: true
4040
loop: false
4141
effect: zoom
4242
width: 100%
@@ -48,12 +48,12 @@ GLightbox is pure Javascript lightbox library with mobile support.
4848
| Option | Default | Description |
4949
|-----------------|---------|--------------------------------------------------------------------------------------------------------------|
5050
| touchNavigation | true | Enable or disable the touch navigation (swipe). |
51-
| loop | true | Loop slides on end. |
51+
| loop | false | Loop slides on end. |
5252
| effect | zoom | Name of the effect on lightbox open. (zoom, fade, none) |
5353
| width | 100% | Default width for inline elements and iframes. You can use any unit for example 90% or 100vw for full width. |
5454
| height | auto | Default height for inline elements and iframes. You can use any unit for example 90%, 100vh or auto. |
55-
| zoomable | True | Enable or disable zoomable images. |
56-
| draggable | True | Enable or disable mouse drag to go prev and next slide. |
55+
| zoomable | true | Enable or disable zoomable images. |
56+
| draggable | true | Enable or disable mouse drag to go prev and next slide. |
5757

5858
Check more options information on [GLightbox Docs](https://github.com/biati-digital/glightbox#lightbox-options).
5959

mkdocs_glightbox/plugin.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class LightboxPlugin(BasePlugin):
1515
""" Add lightbox to MkDocs """
1616

1717
config_scheme = (
18-
("touchNavigation", config_options.Type(bool, default=False)),
18+
("touchNavigation", config_options.Type(bool, default=True)),
1919
("loop", config_options.Type(bool, default=False)),
20-
("effect", config_options.Type(str, default="zoom")),
20+
("effect", config_options.Choice(("zoom", "fade", "none"), default="zoom")),
2121
("width", config_options.Type(str, default="100%")),
2222
("height", config_options.Type(str, default="auto")),
2323
("zoomable", config_options.Type(bool, default=True)),
@@ -50,8 +50,10 @@ def on_post_page(self, output, page, config, **kwargs):
5050
soup.head.append(js_script)
5151

5252
js_code = soup.new_tag("script")
53-
lb_config = dict(self.config)
54-
lb_config = {k: lb_config[k] for k in ["touchNavigation", "loop"]}
53+
plugin_config = dict(self.config)
54+
lb_config = {k: plugin_config[k] for k in ["touchNavigation", "loop", "width", "height", "zoomable", "draggable"]}
55+
lb_config['openEffect'] = plugin_config.get('effect', 'zoom')
56+
lb_config['closeEffect'] = plugin_config.get('effect', 'zoom')
5557
js_code.string = f"const lightbox = GLightbox({json.dumps(lb_config)});"
5658
if config["theme"].name == "material" or "navigation.instant" in config["theme"]._vars.get("features", []):
5759
# support compatible with mkdocs-material Instant loading feature
@@ -62,18 +64,12 @@ def on_post_page(self, output, page, config, **kwargs):
6264

6365
def on_page_content(self, html, page, config, **kwargs):
6466
""" Wrap img tag with archive tag with glightbox class and attributes from config """
65-
66-
lb_data_config = dict(self.config)
67-
lb_data_config = {k: lb_data_config[k] for k in [
68-
"effect", "width", "height", "zoomable", "draggable"]}
6967
soup = BeautifulSoup(html, "html.parser")
7068
imgs = soup.find_all("img")
7169
for img in imgs:
7270
a = soup.new_tag("a")
7371
a["class"] = "glightbox"
7472
a["href"] = img.get("src", "")
75-
for key, val in lb_data_config.items():
76-
a[f"data-{key}"] = val
7773
img.wrap(a)
7874
return str(soup)
7975

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="mkdocs-glightbox",
9-
version="0.1.5",
9+
version="0.1.6",
1010
author="Blueswen",
1111
author_email="[email protected]",
1212
url = "https://blueswen.github.io/mkdocs-glightbox",

0 commit comments

Comments
 (0)