This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
59 lines (54 loc) · 1.48 KB
/
script.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
import ResponsiveDOM from "./src/ResponsiveDOM.js";
const DestroyBtn = document.getElementById("destroy");
const InitBtn = document.getElementById("init");
// ResponsiveDOM.onMediaQueryChange(
// ["(max-width: 768px)", "(min-width: 769px)"],
// [
// () => {
// console.log("Width is less than or equal to 768px");
// },
// () => {
// console.log("Width is greater than or equal to 769px");
// },
// ]
// );
// if (ResponsiveDOM.isMobile()) {
// console.log("Its Mobile");
// } else if (ResponsiveDOM.isTablet()) {
// console.log("Its Tablet");
// } else if (ResponsiveDOM.isDesktop()) {
// console.log("Its Desktop");
// } else if (ResponsiveDOM.isTV()) {
// console.log("Its TV");
// }
const card = ResponsiveDOM.createComponent(".card", {
breakpoints: {
mobile: (component) => {
component.element.style.backgroundColor = "red";
console.log("Mobile view");
},
tablet: (component) => {
component.element.style.backgroundColor = "green";
console.log("Tablet view");
},
desktop: (component) => {
component.element.style.backgroundColor = "blue";
console.log("Desktop view");
},
},
onResize: (component) => {
console.log("Resized");
},
onInit: (component) => {
console.log("Initialized");
},
onDestroy: (component) => {
console.log("Destroyed");
},
});
DestroyBtn.addEventListener("click", () => {
card.destroy();
});
InitBtn.addEventListener("click", () => {
card.init();
});