in src/components/Composer/riseInput.ts [24:55]
export default function riseInput(input: Element, wrap?: Element | null) {
const scrollType = testScrollType();
let scrollTimer: ReturnType<typeof setTimeout>;
const target = wrap || input;
const scrollIntoView = () => {
if (scrollType === 0) return;
if (scrollType === 1) {
document.body.scrollTop = document.body.scrollHeight;
} else {
target.scrollIntoView(false);
}
};
input.addEventListener('focus', () => {
setTimeout(scrollIntoView, 300);
scrollTimer = setTimeout(scrollIntoView, 1000);
});
input.addEventListener('blur', () => {
clearTimeout(scrollTimer);
// 某些情况下收起键盘后输入框不收回,页面下面空白
// 比如:闲鱼、大麦、乐动力、微信
if (scrollType && isIOS) {
// 以免点击快捷短语无效
setTimeout(() => {
document.body.scrollIntoView();
});
}
});
}