after the search bar is focused and the screen height is reduced, let the sheet scroll to top

This commit is contained in:
MaysWind
2025-02-12 00:56:08 +08:00
parent 13cc6a2cf0
commit 2e01e5530c
4 changed files with 48 additions and 12 deletions
+18
View File
@@ -140,6 +140,24 @@ export function scrollToSelectedItem(parentEl: Framework7Dom, containerSelector:
container.scrollTop(targetPos);
}
export function scrollSheetToTop(sheetElement: HTMLElement | undefined, windowNormalInnerHeight: number): void {
if (!sheetElement) {
return;
}
const sheetHeight = sheetElement.offsetHeight;
if (sheetHeight < windowNormalInnerHeight) {
setTimeout(() => {
const windowNewInnerHeight = window.innerHeight;
if (windowNewInnerHeight < windowNormalInnerHeight && sheetHeight < windowNewInnerHeight) {
window.scrollTo({ top: windowNormalInnerHeight - sheetHeight - 24, behavior: "smooth" });
}
}, 300);
}
}
export function useI18nUIComponents() {
const { tt, te } = useI18n();