iOS textarea text hidden when using -webkit-overflow-scrolling: touch

霸气de小男生 提交于 2019-12-03 03:33:03

This issue is triggered by the textarea element within a container using:

-webkit-overflow-scrolling: touch 

in its parent container.

Removing the class solves the problem with the 'initially hidden text not loading' but losing desired inertia scrolling UX.

Adding

-webkit-transform: translateZ(0px) 

to the style of my affected textarea elements solves my problem.

In my particular case I dont believe I will incur in prohibitive performance penalties since my hidden elements that I am yet to scroll to wouldnt be loading rich content (videos/animations/etc) that would tax the VRAM on the mobile device. I am basically taking advantage of the additional rendering context (hardware assisted) being triggered by this, which makes my text render normally, and thus bypassing an iOS BUG.

Great information on translateZ (and its close cousin translate3d(0,0,0)) http://aerotwist.com/blog/on-translate3d-and-layer-creation-hacks/

It seems that when using:

-webkit-overflow-scrolling: touch;

iOS places the form elements in an odd z-index placement where it is visually hidden yet still clickable (knowing where the elements are: can type text, press buttons, etc). The hack-fix until iOS corrects this bug (which is present in both Safari and Chrome on iOS) is to explicitly set a lower z-index on all elements with -webkit-overflow-scrolling: touch set.

For example, if the page doesn't use z-index at all then using:

z-index: -1; -webkit-transform: translateZ(-1); -webkit-overflow-scrolling: touch;

will correct the issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!