-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
69 lines (51 loc) · 2.07 KB
/
Copy pathscript.js
File metadata and controls
69 lines (51 loc) · 2.07 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
class Item{
constructor(title,url,backgroundPositionY){
this.title=title;
this.url=url;
this.backgroundPositionY=backgroundPositionY;
};
}
const itemArray=
[
new Item('DEEP EARTH','images/desktop/image-deep-earth.jpg','end'),
new Item('NIGHT ARCADE','images/desktop/image-night-arcade.jpg','start'),
new Item('SOCCER TEAM VR','images/desktop/image-soccer-team.jpg','start'),
new Item('THE GRID','images/desktop/image-grid.jpg','center'),
new Item('FROM UP ABOVE VR','images/desktop/image-from-above.jpg','start'),
new Item('POCKET BOREALIS','images/desktop/image-pocket-borealis.jpg','start'),
new Item('THE CURIOSITY','images/desktop/image-curiosity.jpg','start'),
new Item('MAKE IT FISHEYE','images/desktop/image-fisheye.jpg','center')
]
window.addEventListener("load",(e)=>{
const fragment=document.createDocumentFragment();
const container=document.querySelector(".item-container");
for(let i=0; i<itemArray.length; i++){
const newItem=document.createElement("DIV");
newItem.innerHTML=`
<div class="item-image image${i}">
</div>
<div class="item-title"><h1>${itemArray[i].title}</h1></div>
`
let newStyle = document.createElement("STYLE");
newStyle.innerHTML=`.image${i}{
background: url('${itemArray[i].url}') no-repeat;
background-size: cover;
background-position-y: ${itemArray[i].backgroundPositionY};
`;
newItem.classList.add("item");
fragment.appendChild(newItem);
fragment.appendChild(newStyle);
}
container.appendChild(fragment);
})
//============================ SANDWICH MENU ======================================//
const sandwichButton = document.querySelector('#sandwich-button')
const navigationMenu = document.querySelector('#navigation-menu');
const body = document.querySelector('body');
let canScroll = true;
sandwichButton.addEventListener("click", () => {
navigationMenu.classList.toggle('navigation-menu-open')
sandwichButton.classList.toggle('sandwich-button-open')
canScroll = !canScroll;
body.style['overflow-y'] = `${canScroll? 'auto':'hidden'}`
})