Sidebar singleton
This commit is contained in:
29
scripts/SideBar.ts
Normal file
29
scripts/SideBar.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { TouchController } from "./TouchController"
|
||||
|
||||
export class SideBar {
|
||||
element: HTMLElement
|
||||
touchController: TouchController
|
||||
|
||||
constructor(element) {
|
||||
this.element = element
|
||||
|
||||
document.body.addEventListener("click", e => {
|
||||
if(document.activeElement.id === "search")
|
||||
return;
|
||||
|
||||
this.hide()
|
||||
})
|
||||
|
||||
this.touchController = new TouchController()
|
||||
this.touchController.leftSwipe = () => this.hide()
|
||||
this.touchController.rightSwipe = () => this.show()
|
||||
}
|
||||
|
||||
show() {
|
||||
this.element.classList.add("sidebar-visible")
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.element.classList.remove("sidebar-visible")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user