UNPKG

@tencentcloud/roomkit-web-vue3

Version:

<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,

54 lines (47 loc) 1.4 kB
import { isIOS } from '@tencentcloud/universal-api'; const ua = navigator.userAgent; function getScrollTypeByPlatform() { if (isIOS) { if (/Safari\//.test(ua) || /IOS 11_[0-3]\D/.test(ua)) { // Safari IOS 11.0-11.3 exclude(`scrollTop`/`scrolIntoView` not working) return 0; } // IOS: use `scrollTop` return 1; } // Android: use `scrollIntoView` return 2; } export default function riseInput(input: HTMLElement, target?: HTMLElement) { const scrollType = getScrollTypeByPlatform(); let scrollTimer: ReturnType<typeof setTimeout>; if (!target) { // eslint-disable-next-line no-param-reassign target = input; } const scrollIntoView = () => { if (scrollType === 0) return; if (scrollType === 1) { document.body.scrollTop = document.body.scrollHeight; } else { target?.scrollIntoView(false); } }; input.addEventListener('focus', () => { const timer = setTimeout(() => { scrollIntoView(); clearTimeout(timer); }, 300); scrollTimer = setTimeout(scrollIntoView, 1000); }); input.addEventListener('blur', () => { clearTimeout(scrollTimer); // Handle IOS issues about keyboard is hidden but page not refreshed if (scrollType && isIOS) { const timer = setTimeout(() => { document.body.scrollIntoView(); clearTimeout(timer); }); } }); }