forked from regisb/reveal.js-fullscreen-img
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfullscreen-img.js
48 lines (43 loc) · 1.61 KB
/
fullscreen-img.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Look for sections that have a fullscreen-img attribute and set this image as
// the body background image whenever this section is displayed.
// TODO insert image with reveal transition
var BGR;
function fullscreen(event) {
var url = event.currentSlide.getAttribute("fullscreen-img");
if(url) {
if(typeof BGR == "undefined")
{
// Store background value
BGR = document.body.style.background;
}
// Set image from fullscreen-img attribute as body background
document.body.style.backgroundImage = "url('" + url + "')";
var size = event.currentSlide.getAttribute("fullscreen-size");
if(size != "contain") {
document.body.style.backgroundSize = "cover";
}
else {
// Put image in 'contain' mode with black background
// TODO store background color and use it. This is possible by regexping
// the background property and replacing the 2nd value by the image url.
// See http://www.w3schools.com/cssref/css3_pr_background.asp
document.body.style.backgroundColor = "#000000";
document.body.style.backgroundSize = "contain";
document.body.style.backgroundRepeat = "no-repeat";
document.body.style.backgroundAttachment = "fixed";
document.body.style.backgroundPosition = "center center";
}
}
else {
if(typeof BGR != "undefined") {
document.body.style.backgroundImage = "none";
document.body.style.background = BGR;
}
}
}
Reveal.addEventListener('ready', function(event) {
fullscreen(event);
}, false );
Reveal.addEventListener('slidechanged', function(event) {
fullscreen(event);
}, false );