azerion / phaser-input

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

Setting to prevent page scroll on input text focus #13

Closed CreativeSparkStudios closed 7 years ago

CreativeSparkStudios commented 8 years ago

I'm using this plugin for a phaser game, when players enter their name for the high score list, and everything is working very well. One small issue, though, is that the html page that the game is embedded in scrolls to the very top of the page when the text field is clicked. This happens in both Chrome, FireFox, Opera, Edge, and IE.

I'm wondering if it would be possible to add a flag that could prevent this behaviour? Or maybe there's some workaround for it?

AleBles commented 8 years ago

Hmm yeah, we made the assumption with this plugin that the game is mostly on the top of the page. We have hidden input boxes placed outside the screen (I think there was an issue with them beeing under the canvas) and I'm thinking this makes your browser scroll to the top.

It doesn't happen with any of our games, because we put them all in iframes. I could have a look at either placing the input fields somewhere else, or seeing if I can disable the browsers default behaviour to no scroll to the active input fields

CreativeSparkStudios commented 8 years ago

Thanks for the explanation. Either of those solutions would be great.

CreativeSparkStudios commented 7 years ago

Awesome, thanks :-)

flafrancesca commented 6 years ago

Hi,

i have the same problem. My game is not at top of the page; so, when i click on the input field, the page scroll to top.

I'm using phaser-input - version 2.0.5 .

Thank you for your support.