🔑 added mobile events in main 🚏

This commit is contained in:
Matei Adriel 2019-06-04 18:46:38 +00:00
parent b2a8e3bf96
commit 2a790a51a9

View file

@ -14,7 +14,7 @@ manager.save()
manager.update() manager.update()
window.onerror = (message: string, url: string, lineNumber: number): boolean => { window.onerror = (message: string, url: string, lineNumber: number): boolean => {
error(message,"",{ error(message, "", {
...manager.alertOptions, ...manager.alertOptions,
onclick: () => modal({ onclick: () => modal({
no: "", no: "",
@ -51,16 +51,25 @@ const handleEvent = <T>(e: T, func: (e: T) => any) => {
manager.barAlpha.next("0") manager.barAlpha.next("0")
} }
render(html` const moveHandler = (e: MouseEvent) => handleEvent(e, (e: MouseEvent) => {
<div @mousemove=${(e: MouseEvent) => handleEvent(e, (e: MouseEvent) => {
manager.handleMouseMove(e) manager.handleMouseMove(e)
screen.updateMouse(e) screen.updateMouse(e)
})} })
render(html`
<div @mousemove=${moveHandler}
@touchmove=${moveHandler}
@mousedown=${(e: MouseEvent) => handleEvent(e, () => @mousedown=${(e: MouseEvent) => handleEvent(e, () =>
manager.handleMouseDown() manager.handleMouseDown()
)}
@touchdown=${(e: MouseEvent) => handleEvent(e, () =>
manager.handleMouseDown()
)} )}
@mouseup=${(e: MouseEvent) => handleEvent(e, () => @mouseup=${(e: MouseEvent) => handleEvent(e, () =>
manager.handleMouseUp() manager.handleMouseUp()
)}
@touchup=${(e: MouseEvent) => handleEvent(e, () =>
manager.handleMouseUp()
)} )}
@wheel=${(e: MouseEvent) => handleEvent(e, (e: WheelEvent) => @wheel=${(e: MouseEvent) => handleEvent(e, (e: WheelEvent) =>
screen.handleScroll(e) screen.handleScroll(e)