修复web阅读上下方向键二段跳的问题

This commit is contained in:
StanHustler 2023-09-23 20:28:28 +08:00 committed by Strato69
parent 0b828581ca
commit 8349fda250
4 changed files with 16 additions and 5 deletions

View File

@ -79,6 +79,7 @@
"watchEffect": true,
"watchPostEffect": true,
"watchSyncEffect": true,
"toValue": true
"toValue": true,
"WritableComputedRef": true
}
}

View File

@ -1,6 +1,7 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
@ -81,5 +82,5 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue'
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
}

View File

@ -3,11 +3,9 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'
export {}
declare module '@vue/runtime-core' {
declare module 'vue' {
export interface GlobalComponents {
BookItems: typeof import('./components/BookItems.vue')['default']
CatalogItem: typeof import('./components/CatalogItem.vue')['default']

View File

@ -446,6 +446,15 @@ const handleKeyPress = (event) => {
break;
}
};
//
const ignoreKeyPress = (event) => {
if (event.key === "ArrowUp" || event.key === "ArrowDown") {
event.preventDefault();
event.stopPropagation();
}
};
onMounted(() => {
//
let bookUrl = sessionStorage.getItem("bookUrl");
@ -484,6 +493,7 @@ onMounted(() => {
getContent(chapterIndex, true, chapterPos);
window.addEventListener("keyup", handleKeyPress);
window.addEventListener("keydown", ignoreKeyPress);
// Safari < 14
document.addEventListener("visibilitychange", onVisibilityChange);
//
@ -505,6 +515,7 @@ onMounted(() => {
onUnmounted(() => {
window.removeEventListener("keyup", handleKeyPress);
window.removeEventListener("keydown", ignoreKeyPress);
window.removeEventListener("resize", onResize);
// Safari < 14
document.removeEventListener("visibilitychange", onVisibilityChange);