From f3bf5f88b5afe0ee54838645eb96a458a386bedc Mon Sep 17 00:00:00 2001 From: MoonLeeeaf <150461955+MoonLeeeaf@users.noreply.github.com> Date: Sun, 19 May 2024 23:11:31 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=BD=AF=E9=94=AE=E7=9B=98=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=B8=83=E5=B1=80=EF=BC=88=E6=B5=8B=E8=AF=95=E4=B8=AD?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ling_chair_http/index.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ling_chair_http/index.js b/ling_chair_http/index.js index 8904b65..ec197a6 100644 --- a/ling_chair_http/index.js +++ b/ling_chair_http/index.js @@ -21,6 +21,11 @@ const UrlArgs = new URL(location.href).searchParams +// https://www.ruanyifeng.com/blog/2021/09/detecting-mobile-browser.html +function isMobile() { + return ('ontouchstart' in document.documentElement); +} + function setOnRightClick(e, cb) { if (!(e instanceof jQuery)) e = $(e) @@ -355,6 +360,7 @@ class ChatMsgAdapter { static minMsgId static time static bbn + static resizeDick // 切换聊天对象 static async switchTo(name, type) { viewBinding.tabChatSeesion.show() @@ -536,7 +542,21 @@ class ChatMsgAdapter { }*/ // 自动调整使输入框置底 CSS真tm靠不住啊 static initInputResizer() { - let resize = () => viewBinding.pageChatSeesion.height(window.innerHeight - viewBinding.inputToolbar.height() - $("header.mdui-appbar").height() - viewBinding.chatTab.height() - 50) + // 实验表面移动端切出输入法时会触发1-2次resize事件 + // 可以利用这个特性来实现自动滚动文本 + let resize = () => { + viewBinding.pageChatSeesion.height(window.innerHeight - viewBinding.inputToolbar.height() - $("header.mdui-appbar").height() - viewBinding.chatTab.height() - 50) + let ledi = this.resizeDick - window.innerHeight + if (isMobile()) viewBinding.chatPager.get(0).scrollBy({ + // 5.19晚10:56分调配出来的秘方 + // < 0 为窗口变大 + // cnm的,调试十万次就你tm检测不到底是吧,就你语法天天错误是吧 + // 欺负我现在用不了电脑 + top: -(ledi) * ( (ledi < 0 && this.isAtBottom()) ? 6 : -1 ), // (ledi < 0 ? 6 : 6), + behavior: 'smooth' + }) + this.resizeDick = window.innerHeight + } window.addEventListener("resize", resize) resize() }