-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.js
More file actions
35 lines (34 loc) · 1.15 KB
/
ui.js
File metadata and controls
35 lines (34 loc) · 1.15 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
class animator{
page;
container;
currentPage;
constructor(containerId){
//Tentukan container halaman
this.container = document.getElementById(containerId);
//Dapatkan template halaman
this.page = document.getElementsByTagName("template");
}
pageSelect(slideId,pageSpecialFunc){
//Dapatkan template
try {
var child = this.page[slideId].content.cloneNode(true);
} catch (error) {
//Bila gagal log page not found
console.log("Page not found");
return false;
}
if(this.currentPage != undefined){
//kalau container tidak kosong, kosongkan dulu
this.container.removeChild(this.currentPage);
}
//Buatkan subcontainer untuk laman
var miniContainer = document.createElement("section");
miniContainer.className = "container";
miniContainer.appendChild(child);
//Bila ada special function jalankan special function
this.currentPage = this.container.appendChild(miniContainer);
if(pageSpecialFunc != null){
pageSpecialFunc();
}
}
}