Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll protection needed #2

Open
BarnabasSzabolcs opened this issue Nov 30, 2021 · 0 comments
Open

Scroll protection needed #2

BarnabasSzabolcs opened this issue Nov 30, 2021 · 0 comments

Comments

@BarnabasSzabolcs
Copy link

Hi Adam!

Scrolling needs to be prevented when a textarea is clicked.
I have added a textarea to Your demo page with {position: absolute; top: 0; bottom: 0; ... } and found that red areas appear when I tap on the textarea. I have added the following callback to Your demo page and it worked out well:

var scrollTextareaInstead = function(){
  if (window.scrollY>0 && document.activeElement.tagName==='TEXTAREA'){
      document.activeElement.scrollTop += window.scrollY+60;  // it is nice to raise the content a bit more than necessary
      window.scrollTo(0,0);
  }
}
window.addEventListener('scroll', scrollTextareaInstead);

This seems to keep the clicked content within the visible area.

(One issue with my sketch may be that a footer bar would cover the clicked text in the textarea - Safari does not scroll up high enough, and does not scroll at all if the tap is higher than the keyboard's height.
Apple devs seem to have the same problem with Notes, and they just scroll the text into view if the text doesn't scroll high enough.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant