+ 4

How to make the scrolling on app not awkward?

I have the problem that when I have a code (most of the time in games) where the player needs to move the finger on the screen to do something, the entire screen moves. I have solved that with CSS now but it's still awkward, since the coordinates of the touch event are off and kind of messing me up... In this code it becomes quite apparent when you try to go up and down without letting the finger go: https://code.sololearn.com/W6qzpzgF5Qac/?ref=app Hope somebody can help me...

26th Feb 2019, 8:26 PM
Anton Böhler
Anton Böhler - avatar
5 Respuestas
+ 6
Aha! If I change lines 51 and 52 to: var x = (e.clientX || e.targetTouches[0].clientX) - 10; var y = (e.clientY || e.targetTouches[0].clientY) - 90; And I add in the CSS: html { position: fixed; } Then it works for me!
5th Mar 2019, 9:14 PM
Rowsej
Rowsej - avatar
+ 6
You need to set html { position: fixed; } and it should work.
26th Feb 2019, 8:58 PM
Rowsej
Rowsej - avatar
+ 4
Hmm... that’s really strange. It doesn’t happen in my code, but it does on yours. Sorry, I don’t know how to fix this.
28th Feb 2019, 5:03 AM
Rowsej
Rowsej - avatar
+ 1
Rowsej , Idid that already but the coordinates of the touchevent aren't the ones you would expect. it's when you go up the effectivness of going up decreses the higher you go. ... 😅
27th Feb 2019, 10:00 PM
Anton Böhler
Anton Böhler - avatar
+ 1
now it works, sorry I didn't notice that you anwsered ... 😅
21st Mar 2019, 8:49 PM
Anton Böhler
Anton Böhler - avatar