Skip to content

Commit 54ddb9d

Browse files
committed
minor fixes
1 parent 9967490 commit 54ddb9d

9 files changed

+113
-77
lines changed

Diff for: README.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ That is the same custom like button from above example, just shorter but also no
958958
959959
You can use this feature completely by markup by providing a query selector as "src" which points to a node in your document.
960960

961-
#### Using Auto-Mount / Auto-Unmount
961+
### Using Auto-Mount / Auto-Unmount
962962

963963
You can use a hidden backstore optionally which holds the fragments to be inserted as a slide, e.g.:
964964

@@ -980,6 +980,39 @@ Provide a __dom query selector__ as "src" which points to a node in your documen
980980

981981
When closing the gallery or change the page to another slide, the fragment will automatically move back to its original position (the hidden backstore in this example).
982982

983+
### Custom Elements (API-only)
984+
985+
You can add nodes as slide which are not part of the document also via the API (e.g. fragments, templates, offscreen nodes). This way you can create your own full customized slides with its own interactions inside them. Also, you can create an iframe to load extern contents.
986+
987+
#### Example: Youtube Video
988+
989+
You can create your own fragments/templates and add the root node directly as "src":
990+
991+
```js
992+
Spotlight.show([{
993+
media: "node",
994+
src: (function(){
995+
const iframe = document.createElement("iframe");
996+
iframe.src = "https://www.youtube.com/embed/tgbNymZ7vqY";
997+
iframe.height = "auto";
998+
return iframe;
999+
}())
1000+
}]);
1001+
```
1002+
1003+
#### Example: Templating Engine
1004+
1005+
Or use your preferred templating engine and add the root node as "src":
1006+
1007+
```js
1008+
Mikado(template).mount(root).render(data);
1009+
1010+
Spotlight.show([{
1011+
media: "node",
1012+
src: root
1013+
}]);
1014+
```
1015+
9831016
<a name="api" id="api"></a>
9841017
## Spotlight API
9851018

Diff for: dist/css/spotlight.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/js/spotlight.min.js

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/spotlight.bundle.js

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: index.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,16 @@ <h1>
164164
button: "Close Gallery",
165165
onclick: Spotlight.close,
166166
like: false
167-
}];
167+
}/*,{
168+
media: "node",
169+
control: "next,prev,close",
170+
src: (function(){
171+
const iframe = document.createElement("iframe");
172+
iframe.src = "https://www.youtube.com/embed/tgbNymZ7vqY";
173+
iframe.height = "auto";
174+
return iframe;
175+
}())
176+
}*/];
168177

169178
window.showGallery = function(index){
170179

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spotlight.js",
3-
"version": "0.7.42",
3+
"version": "0.7.43",
44
"description": "Modern HTML5 Image Gallery",
55
"homepage": "https://github.com/nextapps-de/spotlight/",
66
"author": "Thomas Wilkerling",

Diff for: src/css/spotlight.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
pointer-events: auto;
2424
}
2525
#spotlight.white {
26-
color: #000;
26+
color: #212529;
2727
background-color: #fff;
2828
}
2929
#spotlight.white .spl-spinner,
@@ -39,6 +39,10 @@
3939
#spotlight.white .spl-footer {
4040
background-color: rgba(255, 255, 255, 0.65);
4141
}
42+
#spotlight.white .spl-button {
43+
background: #212529;
44+
color: #fff;
45+
}
4246
#spotlight .cover {
4347
object-fit: cover;
4448
height: 100%;

Diff for: src/css/spotlight.less

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
}
4040
&.white {
4141
& {
42-
color: #000;
42+
color: #212529;
4343
background-color: #fff;
4444
}
4545
.spl-spinner,
@@ -55,6 +55,10 @@
5555
.spl-footer{
5656
background-color: rgba(255, 255, 255, 0.65);
5757
}
58+
.spl-button{
59+
background: #212529;
60+
color: #fff;
61+
}
5862
}
5963
.cover{
6064
object-fit: cover;

Diff for: src/js/spotlight.js

+16-30
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,16 @@ function init_slide(index, direction){
562562
media = document.querySelector(media);
563563
}
564564

565-
media._root || (media._root = media.parentNode);
566-
update_media_viewport();
565+
if(media){
567566

568-
options_spinner && removeClass(widget, "spinner");
569-
panel.appendChild(media);
567+
media._root || (media._root = media.parentNode);
568+
update_media_viewport();
569+
570+
options_spinner && removeClass(widget, "spinner");
571+
panel.appendChild(media);
570572

571-
init_slide(index, direction);
573+
init_slide(index, direction);
574+
}
572575
}
573576
else{
574577

@@ -1273,21 +1276,10 @@ export function close(hashchange){
12731276

12741277
history.go(hashchange === true ? -1 : -2);
12751278

1276-
if(playing){
1277-
1278-
play(false);
1279-
}
1280-
1281-
if(media){
1282-
1283-
checkout(media);
1284-
}
1285-
1286-
if(hide){
1287-
1288-
hide = clearTimeout(hide);
1289-
}
1290-
1279+
playing && play();
1280+
media && checkout(media);
1281+
hide && menu(true);
1282+
toggle_theme && theme();
12911283
options_onclose && options_onclose();
12921284
}
12931285

@@ -1356,7 +1348,7 @@ export function next(e){
13561348
}
13571349
else if(playing){
13581350

1359-
play(false);
1351+
play();
13601352
}
13611353
}
13621354
}
@@ -1367,19 +1359,13 @@ export function goto(slide){
13671359

13681360
if(slide !== current_slide){
13691361

1370-
playing || autohide();
1371-
1372-
if(playing){
1373-
1374-
playing = clearInterval(playing);
1375-
play();
1376-
}
1362+
playing ? play() : autohide();
13771363

13781364
const direction = slide > current_slide;
13791365

13801366
current_slide = slide;
1381-
13821367
setup_page(direction);
1368+
options_autoplay && play();
13831369

13841370
return true;
13851371
}
@@ -1469,7 +1455,7 @@ function prepare(){
14691455
src: determine_src(anchor, size, options),
14701456
title: parse_option("title",
14711457
anchor["alt"] || anchor["title"] ||
1472-
((tmp = getByTag("img", anchor)[0]) && (tmp["alt"] || tmp["title"]))
1458+
((anchor.nodeType === 1) && (tmp = getByTag("img", anchor)[0]) && (tmp["alt"] || tmp["title"]))
14731459
)
14741460
};
14751461

0 commit comments

Comments
 (0)