Skip to content
Snippets Groups Projects
Commit 72c5011b authored by Giovanni Caruso's avatar Giovanni Caruso
Browse files

Fixed absolute value in point x

parent ecc70dbd
Branches
No related tags found
1 merge request!70Apple pen
Pipeline #107522 canceled
...@@ -200,10 +200,14 @@ const onRoomConnect = (room_) => { ...@@ -200,10 +200,14 @@ const onRoomConnect = (room_) => {
HTML.undoButton.classList.remove("disabled") HTML.undoButton.classList.remove("disabled")
}) })
const topPanelHeight = HTML.topPanel.offsetHeight
console.log("Top panel height: " + topPanelHeight)
HTML.canvas.addEventListener("touchstart", (e) => { HTML.canvas.addEventListener("touchstart", (e) => {
e.preventDefault() e.preventDefault()
let pressure = 0 let pressure = 0
let x, y let x, y
const topPanelHeight = HTML.topPanel.offsetHeight
if ( if (
e.touches && e.touches &&
e.touches[0] && e.touches[0] &&
...@@ -213,11 +217,11 @@ const onRoomConnect = (room_) => { ...@@ -213,11 +217,11 @@ const onRoomConnect = (room_) => {
pressure = e.touches[0]["force"] pressure = e.touches[0]["force"]
} }
x = e.touches[0].pageX x = e.touches[0].pageX
y = e.touches[0].pageY - 100 y = e.touches[0].pageY - topPanelHeight
} else { } else {
pressure = 1.0 pressure = 1.0
x = e.pageX x = e.pageX
y = e.pageY - 100 y = e.pageY - topPanelHeight
} }
clearRecognizedUpcoming() clearRecognizedUpcoming()
...@@ -243,6 +247,7 @@ const onRoomConnect = (room_) => { ...@@ -243,6 +247,7 @@ const onRoomConnect = (room_) => {
HTML.canvas.addEventListener("touchmove", (e) => { HTML.canvas.addEventListener("touchmove", (e) => {
let pressure = 0 let pressure = 0
let x, y let x, y
const topPanelHeight = HTML.topPanel.offsetHeight
if ( if (
e.touches && e.touches &&
e.touches[0] && e.touches[0] &&
...@@ -252,11 +257,11 @@ const onRoomConnect = (room_) => { ...@@ -252,11 +257,11 @@ const onRoomConnect = (room_) => {
pressure = e.touches[0]["force"] pressure = e.touches[0]["force"]
} }
x = e.touches[0].pageX x = e.touches[0].pageX
y = e.touches[0].pageY - 100 y = e.touches[0].pageY - topPanelHeight
} else { } else {
pressure = 1.0 pressure = 1.0
x = e.pageX x = e.pageX
y = e.pageY - 100 y = e.pageY - topPanelHeight
} }
if (room == null) { if (room == null) {
......
...@@ -34,3 +34,4 @@ export const strokeRadiusSlider = document.getElementById("range") ...@@ -34,3 +34,4 @@ export const strokeRadiusSlider = document.getElementById("range")
export const output = document.getElementById("value") export const output = document.getElementById("value")
export const labelColours = document.getElementById("colours") export const labelColours = document.getElementById("colours")
export const userInfo = document.getElementById("user-avatar") export const userInfo = document.getElementById("user-avatar")
export const topPanel = document.getElementById("top-panel")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment