-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
71 lines (61 loc) · 2.19 KB
/
scripts.js
File metadata and controls
71 lines (61 loc) · 2.19 KB
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
let imagesData = [
{
photo: 'images/DSC_0086.jpg',
title: 'San Francisco',
description: 'The beautiful Golden Gate bridage'
},
{
photo: 'images/DSC_0131.jpg',
title: 'San Francisco',
description: 'During our 16 days trip we have visited San Franscisco. This picture was taken on the beach.'
},
{
photo: 'images/DSC_0140.jpg',
title: 'Muir Woods',
description: 'North from San Francisco there is an ancient forest called Moir Woods'
},
{
photo: 'images/DSC_0235.jpg',
title: 'San Francisco - Japan garaden.',
description: 'There are a lot of beautiful parks in San Francisco. One of my favorite was this Japan style garden.'
},
{
photo: 'images/DSC_0378.jpg',
title: 'Universal Studios - Hogwarts School of Witchcraft and Wizardry',
description: 'One of the best stop durign our trip was Universal Studios. We had a wonderful day here. I wish we could go back sometime.'
}]
let currentPhoto = 0;
// let imagesData = [photo1, photo2, photo3, photo4, photo5]
let loadPhoto = (currentPhoto) => {
$('#photo').attr('src', imagesData[currentPhoto].photo);
$('#photo-title').text(imagesData[currentPhoto].title);
$('#photo-description').text(imagesData[currentPhoto].description);
$(`.thumbnail`).css('box-shadow', '0px 15px 10px -15px #111').css('height', '60px').css('width', '60px');
$(`.thumbnail[data-index=${currentPhoto}]`).css('box-shadow', '0px 15px 10px -10px #111').css('height', '70px').css('width', '70px');
}
$('.right').click(() => {
if (currentPhoto < imagesData.length - 1) {
currentPhoto++;
} else {
currentPhoto = 0;
}
loadPhoto(currentPhoto);
});
$('.left').click(() => {
if (currentPhoto > 0) {
currentPhoto--;
} else {
currentPhoto = imagesData.length - 1;
}
loadPhoto(currentPhoto);
});
imagesData.forEach((item, index) => {
$('ul').append(`<li><img class="thumbnail" data-index="${index}" src=${item.photo}></li>`);
$('.thumbnail').click((event) => {
let indexClicked = $(event.target).attr('data-index');
let numberIndex = parseInt(indexClicked);
currentPhoto = numberIndex;
loadPhoto(currentPhoto);
})
});
loadPhoto(currentPhoto);