azerion / phaser-input

Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
MIT License
201 stars 64 forks source link

Scroll problem on input text focus #62

Open flafrancesca opened 6 years ago

flafrancesca commented 6 years ago

Hi,

i have the same problem of issue #19 . My game is not at top of the page; so, when i click on the input field, the page scroll to top and it is impossible to write on it.

I'm using phaser-input - version 2.0.5 .

Thank you for your support.

flafrancesca commented 6 years ago

Maybe i have solved my scroll problem:

var canvasTopX = this.game.canvas.getBoundingClientRect().top + document.documentElement.scrollTop;

insted of

var canvasTopX = this.game.canvas.getBoundingClientRect().top + document.body.scrollTop;

It seemed to fix the problem when the input gains focus because I have seen that the instruction document.body.scrollTop returns always 0.