forked from XiaoMo/ChatGPT-Next-Web
feat: disable auto-scroll on ios device
This commit is contained in:
parent
a2baad9c7f
commit
caec01269a
@ -29,7 +29,7 @@ import DownloadIcon from "../icons/download.svg";
|
|||||||
import { Message, SubmitKey, useChatStore, Theme } from "../store";
|
import { Message, SubmitKey, useChatStore, Theme } from "../store";
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./settings";
|
||||||
import { showModal } from "./ui-lib";
|
import { showModal } from "./ui-lib";
|
||||||
import { copyToClipboard, downloadAs } from "../utils";
|
import { copyToClipboard, downloadAs, isIOS } from "../utils";
|
||||||
|
|
||||||
export function Markdown(props: { content: string }) {
|
export function Markdown(props: { content: string }) {
|
||||||
return (
|
return (
|
||||||
@ -177,9 +177,8 @@ export function Chat(props: { showSideBar?: () => void }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dom = latestMessageRef.current;
|
const dom = latestMessageRef.current
|
||||||
const rect = dom?.getBoundingClientRect();
|
if (dom && !isIOS()) {
|
||||||
if (dom && rect && rect?.top >= document.documentElement.clientHeight - 120) {
|
|
||||||
dom.scrollIntoView({
|
dom.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "end"
|
block: "end"
|
||||||
|
@ -30,3 +30,8 @@ export function downloadAs(text: string, filename: string) {
|
|||||||
|
|
||||||
document.body.removeChild(element);
|
document.body.removeChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isIOS() {
|
||||||
|
const userAgent = navigator.userAgent.toLowerCase();
|
||||||
|
return /iphone|ipad|ipod/.test(userAgent);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user