Skip to content

Commit e08f9e9

Browse files
committed
update lightbox docs
1 parent 82d0a8a commit e08f9e9

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

src/lightbox.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Lightbox
44
layout: default
55
---
66

7-
# Lightbox
7+
# Lightbox <span class="r-version-badge new">5.2.0</span>
88

99
A lightbox is a modal that displays an image or video in a full-screen overlay. It's great for things like clicking on thumbnails to view a larger [image](#image-lightbox) or [video](#video-lightbox).
1010

@@ -101,18 +101,24 @@ Note that the lightbox feature works on any element, not just images and videos.
101101

102102
## Iframe Lightbox
103103

104-
It's also possible to preview links in iframe lightboxes. The syntax for this is slightly different from how image and video lightboxes work. To enable a link preview, you'll need to add the `data-preview-link` attribute to an anchor tag. It does not accept any value and will always use the anchor's `href` attribute as the source for the iframe.
104+
It's possible to preview links in iframe lightboxes using the `data-preview-link` attribute. When this attribute is added to an `<a>` tag, reveal.js will automatically open the link's `href` in an iframe.
105+
106+
If you want to open an iframe lightbox from another element, you can set the iframe source as a value to the `data-preview-link` attribute.
105107

106108
```html
107109
<a href="https://hakim.se" data-preview-link>Open Hakim's Website</a>
110+
<img src="reveal.png" data-preview-link="https://hakim.se">
108111
```
109112

110113
<div class="reveal reveal-example">
111114
<div class="slides">
112115
<section>
113116
<a href="https://hakim.se" data-preview-link>Open Hakim's Website</a>
117+
<br />
118+
<br />
119+
<img src="/images/logo/reveal-black-text-sticker.png" data-preview-link="https://hakim.se" width="400px">
114120
</section>
115121
</div>
116122
</div>
117123

118-
Note that this will only work if the link allows for embedding. Many domains prevent embedding via `x-frame-options` or `Content-Security-Policy`.
124+
Note that this will only work if the link allows for embedding. Many websites prevent embedding via `x-frame-options` or `Content-Security-Policy`.

src/links.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,21 @@ You can add relative navigation links that work similarly to the built in direct
6363
```
6464

6565
Each navigation element is automatically given an `enabled` class when it's a valid navigation route based on the current slide. For example, if you're on the first slide only `navigate-right` will have the `enabled` class since it's not possible to navigate towards the left.
66+
67+
## Lightbox Links
68+
69+
If the website you're linking to supports iframe embedding, you can use the `data-preview-link` attribute to open the link in an iframe lightbox. This way you can show an external website without leaving the slide deck. Learn more in the [Lightbox docs](/lightbox/#iframe-lightbox).
70+
71+
```html
72+
<a href="https://hakim.se" data-preview-link>Open Link</a>
73+
```
74+
75+
<div class="reveal reveal-example">
76+
<div class="slides">
77+
<section>
78+
<a href="https://hakim.se" data-preview-link>Open Link</a>
79+
</section>
80+
</div>
81+
</div>
82+
83+
Note that this will only work if the link allows for embedding. Many websites prevent embedding via `x-frame-options` or `Content-Security-Policy`.

src/media.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@ Reveal.initialize({
2929

3030
Note that embedded HTML `<video>`/`<audio>` and YouTube/Vimeo iframes are automatically paused when you navigate away from a slide. This can be disabled by decorating your element with a `data-ignore` attribute.
3131

32+
## Lightbox
33+
34+
You can turn any element into a media lightbox by adding the `data‑preview‑image`, `data‑preview‑video` or `data‑preview‑link` attribute. This will cause the media to open in a full-screen overlay when clicked. Learn more in the [Lightbox docs](/lightbox).
35+
36+
```html
37+
<img src="reveal.png" data-preview-video="video.mp4">
38+
<a href="https://hakim.se" data-preview-link>Open Link</a>
39+
```
40+
41+
<div class="reveal reveal-example">
42+
<div class="slides">
43+
<section>
44+
<img src="/images/logo/reveal-black-text-sticker.png" data-preview-video="https://static.slid.es/site/homepage/v1/homepage-video-editor.mp4" width="400px">
45+
<br />
46+
<br />
47+
<a href="https://hakim.se" data-preview-link>Open Link</a>
48+
</section>
49+
</div>
50+
</div>
51+
52+
53+
3254
## Lazy Loading
3355

3456
When working on presentations with a lot of media or iframe content it's important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the `viewDistance` configuration option.

yarn.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5427,7 +5427,7 @@ reusify@^1.0.4:
54275427

54285428
"reveal.js@github:hakimel/reveal.js#master":
54295429
version "5.2.0"
5430-
resolved "https://codeload.github.com/hakimel/reveal.js/tar.gz/edb69c840cf3073f98f7bdd7a3148a7e1b176f5f"
5430+
resolved "https://codeload.github.com/hakimel/reveal.js/tar.gz/47ee25dd1932a6e4f997e635c6fac8d25a2deae9"
54315431

54325432
rimraf@^2.7.1:
54335433
version "2.7.1"
@@ -5758,6 +5758,7 @@ stream-shift@^1.0.0:
57585758
integrity sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==
57595759

57605760
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
5761+
name string-width-cjs
57615762
version "4.2.3"
57625763
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
57635764
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -5799,6 +5800,7 @@ string_decoder@~1.1.1:
57995800
safe-buffer "~5.1.0"
58005801

58015802
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
5803+
name strip-ansi-cjs
58025804
version "6.0.1"
58035805
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
58045806
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==

0 commit comments

Comments
 (0)