Reality123b commited on
Commit
89c369e
·
verified ·
1 Parent(s): 74d03ae

Update application/static/js/components/navbar.js

Browse files
application/static/js/components/navbar.js CHANGED
@@ -1,68 +1,36 @@
1
- class Navbar {
2
- constructor(UIManager) {
3
- this.uiManager = UIManager;
4
- this.menu = this.uiManager.menu;
5
- this.hamburger = this.uiManager.hamburger;
6
- this.container = this.uiManager.container;
7
- this.state = true; // true = open, false = closed
8
- this.menuWidth = 0;
9
- this.containerWidth = this.container.clientWidth;
10
- this.NAV_AREA_LARGE = 20; // % of window width
11
- this.NAV_AREA_MEDIUM = 25; // % of window width
12
- this.NAV_AREA_SMALL = 60; // % of window width
13
- this.ANIMATION_STEP = 5; // pixels per frame
14
- }
15
-
16
- calculateNavArea() {
17
- if (window.innerWidth > 785) {
18
- return window.innerWidth < 1100
19
- ? window.innerWidth * (this.NAV_AREA_MEDIUM / 100)
20
- : window.innerWidth * (this.NAV_AREA_LARGE / 100);
21
- }
22
- return window.innerWidth * (this.NAV_AREA_SMALL / 100);
23
- }
24
-
25
- toggleState() {
26
- if (this.state) {
27
- this.nav.close();
28
- } else {
29
- this.nav.open();
30
- }
31
- this.state = !this.state;
32
- }
33
-
34
- animateNav(action) {
35
- if (action === 'open' && this.menuWidth < this.navArea) {
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