leecade / leecade/webapp-debug

H5 键盘挡住输入框

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

  1. 输入框获取交焦点之后,使用定时器循环判断浏览器可视窗口的大小,然后设置整个页面的滚动距离。
$('input').on('focus', function() {
                    var h = this.offsetHeight,
                        t = this.offsetTop;
                    var timer = setInterval(function() {
                        var hs2 = document.documentElement.clientHeight || document.body.clientHeight;
                        var tH = window.scrollY;
                        if (isAndroid && hScreen>hs2) {
                                //使用原生
                                // document.body.scrollTop = hScreen - hs2;
                                // document.documentElement.scrollTop = hScreen - hs2;
                                // 使用zepto.js库
                                $(document).scrollTop(hScreen - hs2);
                                clearInterval(timer);
                        }
                    }, 100)
                })
  1. 给浏览器添加resize事件,然后判断输入框时候获取当前页面的焦点,

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start by locating the H5 input and focus handling. Compare the timer and resize-event approaches described, and verify that the focused input remains visible when the Android keyboard opens.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.