KilledByAPixel / LittleJS

LittleJS is a fast HTML5 game engine with many features and no dependencies. 🚂 Choo-Choo!
MIT License
3.19k stars 160 forks source link

prevent popups on mobile #69

Closed KilledByAPixel closed 8 months ago

KilledByAPixel commented 8 months ago

Need to prevent the "Create Link" and magnifier lens appearing sometimes on ios mobile in chrome and safari.

Space Huggers

KilledByAPixel commented 8 months ago

I have this mostly fixed by adding "-webkit-touch-callout:none" and preventDefault() to the input event.

However it seems to still still sometimes occasionally happens, not sure why.

KilledByAPixel commented 8 months ago

I have this nearly 100% fixed.

One way I have not been able to fix is if the document loses focus, by changing tabs or minimizing. Then to restore focus it needs to not call e.preventDefault() until the document has focus. So if the user taps and holds in that state, it will cause the link popup to appear. However after the first click and the document has focus again it will be fine.

I also noticed on one project it was necessary change the top level html style tag to prevent this. So if we can find that happens again, this css code can be used to prevent it....


<style>
html, body, canvas
{
user-select:none;  
-webkit-user-select:none;  
-webkit-touch-callout:none;
}
</style>