Spaces:
Sleeping
Sleeping
Update application/static/js/components/navbar.js
Browse files
application/static/js/components/navbar.js
CHANGED
|
@@ -1,68 +1,36 @@
|
|
| 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 |
-
this.menuWidth += this.ANIMATION_STEP;
|
| 37 |
-
} else if (action === 'close' && this.menuWidth > 0) {
|
| 38 |
-
this.menuWidth -= this.ANIMATION_STEP;
|
| 39 |
-
} else {
|
| 40 |
-
return; // Stop animation
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
this.menu.style.width = `${this.menuWidth}px`;
|
| 44 |
-
if(window.innerWidth>775){
|
| 45 |
-
this.container.style.width = `${this.containerWidth - this.menuWidth}px`;
|
| 46 |
-
this.container.style.left = `${this.menuWidth}px`;
|
| 47 |
-
}
|
| 48 |
-
requestAnimationFrame(() => this.animateNav(action));
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
run() {
|
| 52 |
-
this.navArea = this.calculateNavArea();
|
| 53 |
-
this.nav = {
|
| 54 |
-
open: () => this.animateNav('open'),
|
| 55 |
-
close: () => this.animateNav('close'),
|
| 56 |
-
};
|
| 57 |
-
|
| 58 |
-
if (window.innerWidth <= 785) {
|
| 59 |
-
this.state = false;
|
| 60 |
-
} else {
|
| 61 |
-
this.nav.open();
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
this.hamburger.addEventListener('click', () => this.toggleState());
|
| 65 |
-
}
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
export default Navbar
|
|
|
|
| 1 |
+
// application/static/js/components/navbar.js
|
| 2 |
+
class Navbar {
|
| 3 |
+
constructor(UIManager) {
|
| 4 |
+
console.log("Navbar constructor called"); // Keep this
|
| 5 |
+
// this.uiManager = UIManager;
|
| 6 |
+
// this.menu = this.uiManager.menu;
|
| 7 |
+
// this.hamburger = this.uiManager.hamburger;
|
| 8 |
+
// this.container = this.uiManager.container;
|
| 9 |
+
// this.state = true; // true = open, false = closed
|
| 10 |
+
// this.menuWidth = 0;
|
| 11 |
+
// this.containerWidth = this.container.clientWidth;
|
| 12 |
+
// this.NAV_AREA_LARGE = 20; // % of window width
|
| 13 |
+
// this.NAV_AREA_MEDIUM = 25; // % of window width
|
| 14 |
+
// this.NAV_AREA_SMALL = 60; // % of window width
|
| 15 |
+
// this.ANIMATION_STEP = 5; // pixels per frame
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
run() {
|
| 19 |
+
console.log("Navbar run called"); //Keep this
|
| 20 |
+
// this.navArea = this.calculateNavArea();
|
| 21 |
+
// this.nav = {
|
| 22 |
+
// open: () => this.animateNav('open'),
|
| 23 |
+
// close: () => this.animateNav('close'),
|
| 24 |
+
// };
|
| 25 |
+
|
| 26 |
+
// if (window.innerWidth <= 785) {
|
| 27 |
+
// this.state = false;
|
| 28 |
+
// } else {
|
| 29 |
+
// this.nav.open();
|
| 30 |
+
// }
|
| 31 |
+
|
| 32 |
+
// this.hamburger.addEventListener('click', () => this.toggleState());
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
export default Navbar
|