-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor toggle functionality + fix reconnect child/parent
- Loading branch information
1 parent
df53119
commit 8cd129d
Showing
4 changed files
with
70 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// const slider = document.getElementById("show-pdg"); | ||
import { Toggle } from "./toggle.js"; | ||
|
||
export class PdgToggle extends Toggle { | ||
constructor(id) { | ||
super(id); | ||
} | ||
|
||
toggle(infoBoxes, redraw) { | ||
if (this.isSliderActive) { | ||
for (const infoBox of infoBoxes) { | ||
infoBox.updateTexImg(`${infoBox.pdg}`); | ||
} | ||
} else { | ||
for (const infoBox of infoBoxes) { | ||
infoBox.updateTexImg(infoBox.name); | ||
} | ||
} | ||
|
||
redraw(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,13 @@ | ||
const toggle = document.getElementById("toggle"); | ||
const slider = document.getElementById("show-pdg"); | ||
|
||
class Toggle { | ||
constructor() { | ||
export class Toggle { | ||
constructor(id) { | ||
this.isSliderActive = false; | ||
this.slider = document.getElementById(id); | ||
} | ||
|
||
init(infoBoxes, drawAll) { | ||
toggle.style.display = "flex"; | ||
|
||
slider.addEventListener("click", () => { | ||
init(callback) { | ||
this.slider.addEventListener("click", () => { | ||
this.isSliderActive = !this.isSliderActive; | ||
|
||
if (this.isSliderActive) { | ||
for (const infoBox of infoBoxes) { | ||
infoBox.updateTexImg(`${infoBox.pdg}`); | ||
} | ||
} else { | ||
for (const infoBox of infoBoxes) { | ||
infoBox.updateTexImg(infoBox.name); | ||
} | ||
} | ||
|
||
drawAll(); | ||
callback(); | ||
}); | ||
} | ||
} | ||
|
||
export default Toggle; |