fix(reader): stop unwanted page jumps when scrolling (#2699)
This commit is contained in:
@@ -5,6 +5,7 @@ import {ReaderAnnotationService} from '../features/annotations/annotation-render
|
||||
import {ReaderEventService, ViewEvent} from './event.service';
|
||||
|
||||
interface TestView extends HTMLDivElement {
|
||||
isFixedLayout: boolean;
|
||||
addAnnotation: (annotation: {value: string}) => void;
|
||||
addAnnotationSpy: (annotation: {value: string}) => void;
|
||||
}
|
||||
@@ -82,6 +83,7 @@ describe('ReaderEventService', () => {
|
||||
|
||||
function createView(width = 600): TestView {
|
||||
const element = document.createElement('div') as TestView;
|
||||
element.isFixedLayout = true;
|
||||
element.addAnnotationSpy = vi.fn();
|
||||
element.addAnnotation = annotation => {
|
||||
element.addAnnotationSpy(annotation);
|
||||
|
||||
@@ -52,6 +52,7 @@ interface IframeClickMessage {
|
||||
}
|
||||
|
||||
interface EventServiceView extends HTMLElement {
|
||||
isFixedLayout: boolean;
|
||||
addAnnotation(annotation: { value: string }): void;
|
||||
}
|
||||
|
||||
@@ -425,7 +426,7 @@ export class ReaderEventService {
|
||||
const deltaX = touch.clientX - this.touchStartX;
|
||||
const deltaY = Math.abs(touch.clientY - this.touchStartY);
|
||||
|
||||
if (Math.abs(deltaX) >= this.SWIPE_THRESHOLD_PX && Math.abs(deltaX) > deltaY) {
|
||||
if (this.view?.isFixedLayout && Math.abs(deltaX) >= this.SWIPE_THRESHOLD_PX && Math.abs(deltaX) > deltaY) {
|
||||
if (this.isNavigating) return;
|
||||
|
||||
this.isNavigating = true;
|
||||
|
||||
@@ -75,6 +75,7 @@ interface FoliateSearchSectionResult {
|
||||
type FoliateSearchResult = FoliateSearchProgress | FoliateSearchSectionResult | 'done';
|
||||
|
||||
interface FoliateViewElement extends HTMLElement {
|
||||
isFixedLayout: boolean;
|
||||
renderer?: FoliateRenderer | null;
|
||||
book?: FoliateBook;
|
||||
open(target: File | object): Promise<void>;
|
||||
|
||||
Reference in New Issue
Block a user