-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
112 lines (95 loc) · 3.23 KB
/
index.html
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Unsplash me!</title>
<script src="js/unsplash-source.min.js"></script>
<style media="screen">
html,body{
height:100%;
margin:0;
background-color: #000;
}
#thecanvas {
height: auto;
min-height: 100%;
}
/* make keyframes that tell the start state and the end state of our object */
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.fade-in {
opacity:0; /* make things invisible upon start */
-webkit-animation:fadeIn ease-in 1; /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:1.0s;
-moz-animation-duration:1.0s;
animation-duration:1.0s;
}
.bottom-right {
position: absolute;
right: 20px;
bottom: 20px;
}
#thebutton {
/*display: inline-block;*/
/*width: 200px;*/
display: none;
font-size: 1.2em;
padding: 0.4em;
color: #fff;
border: 2px solid #fff;
border-radius: 5px;
text-align: center;
outline: none;
text-decoration: none;
transition: background-color 0.2s ease-out,
border-color 0.2s ease-out;
}
#thebutton:hover,
#thebutton:active {
background-color: #fff; /* fallback */
background-color: rgba(255, 255, 255, 0.4);
border-color: #fff; /* fallback */
border-color: rgba(255, 255, 255, 0.4);
transition: background-color 0.3s ease-in,
border-color 0.3s ease-in;
}
</style>
</head>
<body>
<div id="thecanvas" class="loader">
<a id="thebutton" class="bottom-right" href="#" onclick="load();">Another please!</a>
</div>
</body>
<script type="text/javascript">
function load() {
console.log('carico...');
document.getElementById('thecanvas').style.background = '';
document.getElementById("thecanvas").className = '';
document.getElementById('thebutton').style.display='none';
//costruzione dell'url
var url = new UnsplashPhoto().all()
.width(Math.round(window.innerWidth*0.9))
.height(Math.round(window.innerHeight*0.9))
.fromCategory("nature")
.of("cat")
//.randomize("daily")
.fetch();
url += '='+new Date().getTime(); //trick per forzare il reload del background
var img = new Image();
img.onload = function () {
document.getElementById('thecanvas').style.background = 'url('+img.src+') no-repeat center/cover fixed';
document.getElementById("thecanvas").className = 'fade-in';
document.getElementById('thebutton').style.display='inline-block';
};
//caricamento dell'immagine
img.src = url;
}
load();
</script>
</html>