-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
163 lines (138 loc) · 7.19 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="stickerParent">
<div id="more">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="45.402px" height="45.402px" viewBox="0 0 45.402 45.402" style="enable-background:new 0 0 45.402 45.402;" xml:space="preserve">
<g>
<path d="M41.267,18.557H26.832V4.134C26.832,1.851,24.99,0,22.707,0c-2.283,0-4.124,1.851-4.124,4.135v14.432H4.141
c-2.283,0-4.139,1.851-4.138,4.135c-0.001,1.141,0.46,2.187,1.207,2.934c0.748,0.749,1.78,1.222,2.92,1.222h14.453V41.27
c0,1.142,0.453,2.176,1.201,2.922c0.748,0.748,1.777,1.211,2.919,1.211c2.282,0,4.129-1.851,4.129-4.133V26.857h14.435
c2.283,0,4.134-1.867,4.133-4.15C45.399,20.425,43.548,18.557,41.267,18.557z"></path>
</g>
</svg>
</div>
<div class="categoryParent">
</div>
<div id="parentDiv" class="parentDiv"></div>
</div>
<!-- <div id="go" style="width: fit-content;padding: 0px 10px 0 10px;height: 40px;border: solid #009688 1px;border-radius: 5px;color:#009688;text-align: center;line-height: 40px;">Show Bottom Sheet</div> -->
<div id="bottom-sheet" class="overlays">
<aside class="social" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
<a href="#close" class="btn-close2" aria-hidden="true">X</a>
<div class="switcherParent" id="switcherParent">
<div class="option" id="item1">Item 1</div>
<div class="option" id="item2">Item 2</div>
<div class="selected" id="selected"></div>
</div>
<div id="mainOptions">
<div id="allStickers">All Stickers</div>
<div id="myStickers">My Stickers</div>
</div>
</aside>
<a href="#close" class="btn-close" aria-hidden="true"></a>
</div>
<!-- <script src="index.js"></script> -->
<script>
window.onload = function name(params) {
var categoryParent = document.querySelector('.categoryParent');
var parentDiv = document.querySelector('.parentDiv');
var jsonDatas = new Object();
var stickers = new Array();
var categorys = new Array();
for (let i = 1; i < 60; i++) {
//continue;
var categoryID;
(i > 0 && i <= 15) ? categoryID = 1 : '';
(i > 15 && i <= 25) ? categoryID = 2 : '';
(i > 25 && i <= 30) ? categoryID = 3 : '';
(i > 30 && i <= 40) ? categoryID = 4 : '';
(i > 40 && i <= 45) ? categoryID = 5 : '';
(i > 45 && i <= 50) ? categoryID = 6 : '';
(i > 50 && i <= 55) ? categoryID = 7 : '';
(i > 55 && i <= 60) ? categoryID = 8 : '';
stickers.push(
{
stikerSrc : './stickers/'+i+'.webp',
stikerName : 'stiker_'+i,
categoryID : categoryID
}
);
const result = categorys.filter(category => category.categoryID === categoryID);
if (result.length === 0) {
categorys.push(
{
categorieImg : i+'.webp',
categoryName : 'category_'+i,
categoryID : categoryID,
loaded : false
}
)
categoryParent.innerHTML += '<div class="category_'+categoryID+'"><img src="./stickers/'+i+'.webp"/></div>';
parentDiv.innerHTML += '<div class="box" id="'+categoryID+'"></div>';
}
}
var categorieTab = new Array();
// define an observer instance
var observer = new IntersectionObserver(onIntersection, {
root: parentDiv, // default is the viewport
threshold: .5 // percentage of taregt's visible area. Triggers "onIntersection"
})
function onIntersection(entries, opts){
entries.forEach(entry =>{
let indice = parseInt(entry.target.id);
if(entry.isIntersecting){
console.log(indice)
entry.target.classList.toggle('visible', true);
if (categorys[indice - 1].loaded === false) {
categorys[indice - 1].loaded = true;
stickers.forEach(sticker => {
if(sticker.categoryID == indice) entry.target.innerHTML += '<img class="sticker_'+sticker.categoryID+'" src="'+sticker.stikerSrc+'"/>';
});
}
entry.target.scrollIntoView(true);
if (indice != null) {
let category = document.querySelector('.category_'+indice);
category.style.backgroundColor = 'rgb(204 204 204 / 82%)';
}
}
else
{
if (indice != null) {
let category = document.querySelector('.category_'+indice);
category.style.backgroundColor = 'transparent';
}
entry.target.classList.toggle('visible', false);
/* entry.target.scrollIntoView(true); */
}
});
}
for (let i = 1; i <= categorys.length; i++) {
let idCategorie = 'category_'+i;
let id = i
let elem = document.getElementById(id);
let categorie_ = document.querySelector('.'+idCategorie);
categorie_.onclick = () => {
elem.scrollIntoView(true);
}
/* categorieTab.push(id); */
observer.observe(elem);
}
var stickerParent = document.getElementById('stickerParent');
var close = document.getElementById('close');
more.onclick = function(){
/* stickerParent.style.display = 'none'; */
window.location = "#bottom-sheet";
}
}
</script>
<script src="index.js"></script>
</body>
</html>