-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
117 lines (100 loc) · 4.17 KB
/
index.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
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
113
114
115
116
117
let movies = [
{
name: "falcon and the winter soldier",
des:
"The Falcon and the Winter Soldier is an American television miniseries created by Malcolm Spellman for the streaming service Disney+, based on Marvel Comics featuring the characters Sam Wilson / Falcon and Bucky Barnes / Winter Soldier.",
image: "images/slider 2.png"
},
{
name: "Loki",
des:
"Loki became the first Disney+ show from Marvel Studios to be officially confirmed for a Season 2 in its sixth episode’s post-credits scene, although details are scarce beyond that news. It’s been confirmed that the entire cast will return for the continuation of Loki’s Disney+ story after the Multiverse began falling apart to close out Season 1 in July 2021.",
image: "images/slider 1.png"
},
{
name: "Wanda Vission",
des:
"Wanda basically has a mental breakdown that results in the death of her husband Vision, Hawkeye and a bunch of other people. In the famous House of M storyline on which this show is very loosely based, Wanda creates an alternate reality where Vision and the twins are alive, and they all live together.",
image: "images/slider 3.png"
},
{
name: "raya and the last night",
des:
"Raya and the Last Dragon is a fantasy film set in the fictional land of Kumandra, but that world is inspired by the beautiful cultures of Southeast Asia. Writer Adele Lim emphasized that Kumandra is a fictional land, and that Southeast Asia served as its inspiration.",
image: "images/slider 4.png"
},
{
name: "luca",
des:
"The movie follows Luca Alberto and Giulias story of friendship and adventure in the Italian Riviera Recently Enrico Casarosa director of Luca revealed how his childhood inspired the movie On Disney's official Twitter account Enrico Casarosa shared how his story helped create Luca's story.",
image: "images/slider 5.png"
}
];
const carousel = document.querySelector(".carousel");
let sliders = [];
let slideIndex = 0; // track the current slide
const createSlide = () => {
if (slideIndex >= movies.length) {
slideIndex = 0;
}
// Create DOM Elements
let slide = document.createElement("div");
var imgElement = document.createElement("img");
let content = document.createElement("div");
let h1 = document.createElement("h1");
let p = document.createElement("p");
// attaching all elements
imgElement.appendChild(document.createTextNode(""));
h1.appendChild(document.createTextNode(movies[slideIndex].name));
p.appendChild(document.createTextNode(movies[slideIndex].des));
content.appendChild(h1);
content.appendChild(p);
slide.appendChild(imgElement);
carousel.appendChild(slide);
// setting up images
imgElement.src = movies[slideIndex].image;
slideIndex++;
// setting elements classnames
slide.className = "slider";
content.className = "slide-content";
h1.className = "movie-title";
p.className = "movie-des";
sliders.push(slide);
if (sliders.length) {
sliders[0].style.marginLeft = `calc(-${100 * (sliders.length - 2)}% - ${
30 * (sliders.length - 2)
}px)`;
}
};
for (let i = 0; i < 3; i++) {
createSlide();
}
setInterval(() => {
createSlide();
}, 3000);
// video cards
const videoCards = [...document.querySelectorAll(".video-card")];
videoCards.forEach((item) => {
item.addEventListener("mouseover", () => {
let video = item.children[1];
video.play();
});
item.addEventListener("mouseleave", () => {
let video = item.children[1];
video.pause();
});
});
// card sliders
let cardContainers = [...document.querySelectorAll('.card-container')];
let preBtns = [...document.querySelectorAll('.pre-btn')];
let nxtBtns = [...document.querySelectorAll('.nxt-btn')];
let cardContainers = [...document.querySelectorAll('.card-container')];
let containerDimensions = item.getBoundingClientRect();
let containerWidth= containerDimensions.width;
nxtBtns[i].addEventListener('click', () => {
item.scrollLeft += containerWidth - 200;
})
preBtns[i].addEventListener('click', () => {
item.scrollLeft += containerWidth + 200;
})
}