当前位置:网站首页>Blocking problem after the mobile terminal pulls up the keyboard
Blocking problem after the mobile terminal pulls up the keyboard
2022-06-10 05:29:00 【Laugh and say threethousand】
One , problem
Mobile , Click on input when , Some Android phones pull up the keyboard , It will cover up input.
Two , solve
// Once the initialization is complete , You need to monitor the keyboard
function keyWorld() {
window.addEventListener('resize', () => {
onFocusAddr();
});
}
// Determine whether it is Android or ios
function isAndroid() {
let u = navigator.userAgent;
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; // android Terminal or uc browser
return isAndroid === true;
}
// Android keyboard block input
function onFocusAddr() {
if (!isAndroid()) return; // Judge whether it is an Android machine
nextTick(() => {
let inputDom = myInputRef.value.$el
? myInputRef.value.$el
: myInputRef.value; // Get root node
let boxScrollTop =
document.body.scrollTop || document.documentElement.scrollTop;
let inputRectObject = inputDom.getBoundingClientRect();
let btnRectObject = myBtnRef.value.getBoundingClientRect();
let distanse =
inputRectObject.top + inputDom.offsetHeight - btnRectObject.top;
if (distanse >= 0 && distanse < 120) {
console.log(
' The difference between the two and the top of the window , Greater than zero is masked , It needs to slide up ',
distanse * 2
);
window.scrollTo({
top: boxScrollTop + distanse * 2,
behavior: 'smooth'
});
}
}); // Delay time of keyboard pulling up
}
That is, after the keyboard is pulled up , Judge input Will it be blocked , If it is blocked, control the scroll bar to slide to the position where it is not blocked .
边栏推荐
猜你喜欢
![[Linux < day20 >] - An Introduction to database and container technology](/img/d1/23dfe81887181d76f0c9bb3172341d.png)
[Linux < day20 >] - An Introduction to database and container technology

photoClip.js手机图片上传截取插件

IDC发布《中国云原生市场分析》,蚂蚁集团已成覆盖最全面厂商之一

蚂蚁集团加入低碳专利承诺,向全球无偿开放专利,促进节能减排

Top prize! The leading scientific and technological achievement "new technology" of 2022 digital Expo was awarded to oceanbase database

Zen project management flow

Recursive function Hanoi Tower
![[STM32] transplantation of Hal library on 4-pin 0.96 inch OLED screen - hardware IIC (I)](/img/38/53059d442cfd6d5ed5a940586b363c.jpg)
[STM32] transplantation of Hal library on 4-pin 0.96 inch OLED screen - hardware IIC (I)

第六章 软件测试工具(此章完结)

数字化浪潮来临,如何实现业务敏捷交付和科技持续治理?揭秘蚂蚁 BizStack
随机推荐
High jump wechat JS game source code
Import Base64 collection and export large pictures
一些漂亮的js提示框
JUC realize future
Read leastereo:hierarchical neural architecture search for deep stereo matching
Ant group joined the commitment of low-carbon patents, opened patents to the world free of charge, and promoted energy conservation and emission reduction
Contact QR code generation plug-in qrcode js
IDC发布《中国云原生市场分析》,蚂蚁集团已成覆盖最全面厂商之一
Record the realization of animation effect on the page of small rocket of BiliBili (station B)
继承extends作用
MySQL-进阶CRUD
Powerful development board
How can nlm5 relay acquisition, acquisition and generation instrument save more power?
Daily question - leetcode497 - random points in non overlapping rectangle - prefix and - bisection
js微信小游戏之打蚊子
数字化浪潮来临,如何实现业务敏捷交付和科技持续治理?揭秘蚂蚁 BizStack
[001] analysis of long and difficult sentences one day
顺序查找、二分查找
2022.6.8-----leetcode. one thousand and thirty-seven
Safari's favorites item does not appear on the home page