Don't auto hide scrollbar in platform other than macOS and iOS, closes #9

This commit is contained in:
chrox
2024-12-05 12:02:42 +01:00
parent 32ffaa0e05
commit 9eacf7e203
2 changed files with 16 additions and 1 deletions
@@ -4,6 +4,7 @@ import { BookDoc } from '@/libs/document';
import { BookConfig, BookNote, BookSearchConfig, BookSearchResult } from '@/types/book';
import { useReaderStore } from '@/store/readerStore';
import { useParallelViewStore } from '@/store/parallelViewStore';
import { getOSPlatform } from '@/utils/misc';
import { getStyles } from '@/utils/style';
import { useTheme } from '@/hooks/useTheme';
import { ONE_COLUMN_MAX_INLINE_SIZE } from '@/services/constants';
@@ -78,6 +79,8 @@ const FoliateViewer: React.FC<{
const { getParallels } = useParallelViewStore();
const { themeCode } = useTheme();
const shouldAutoHideScrollbar = ['macos', 'ios'].includes(getOSPlatform());
const progressRelocateHandler = (event: Event) => {
const detail = (event as CustomEvent).detail;
// console.log('relocate:', detail);
@@ -116,7 +119,7 @@ const FoliateViewer: React.FC<{
const detail = (event as CustomEvent).detail;
if (detail.doc) {
const viewSettings = getViewSettings(bookKey)!;
if (viewSettings.scrolled) {
if (viewSettings.scrolled && shouldAutoHideScrollbar) {
handleScrollbarAutoHide(detail.doc);
}
if (!detail.doc.isEventListenersAdded) {
+12
View File
@@ -22,3 +22,15 @@ export const makeSafeFilename = (filename: string, replacement = '_') => {
return safeName.trim();
};
export const getOSPlatform = () => {
const userAgent = navigator.userAgent.toLowerCase();
if (userAgent.includes('macintosh') || userAgent.includes('mac os x')) return 'macos';
if (userAgent.includes('windows nt')) return 'windows';
if (userAgent.includes('linux')) return 'linux';
if (/iphone|ipad|ipod/.test(userAgent)) return 'ios';
if (userAgent.includes('android')) return 'android';
return '';
};