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';
|
import {ReaderEventService, ViewEvent} from './event.service';
|
||||||
|
|
||||||
interface TestView extends HTMLDivElement {
|
interface TestView extends HTMLDivElement {
|
||||||
|
isFixedLayout: boolean;
|
||||||
addAnnotation: (annotation: {value: string}) => void;
|
addAnnotation: (annotation: {value: string}) => void;
|
||||||
addAnnotationSpy: (annotation: {value: string}) => void;
|
addAnnotationSpy: (annotation: {value: string}) => void;
|
||||||
}
|
}
|
||||||
@@ -82,6 +83,7 @@ describe('ReaderEventService', () => {
|
|||||||
|
|
||||||
function createView(width = 600): TestView {
|
function createView(width = 600): TestView {
|
||||||
const element = document.createElement('div') as TestView;
|
const element = document.createElement('div') as TestView;
|
||||||
|
element.isFixedLayout = true;
|
||||||
element.addAnnotationSpy = vi.fn();
|
element.addAnnotationSpy = vi.fn();
|
||||||
element.addAnnotation = annotation => {
|
element.addAnnotation = annotation => {
|
||||||
element.addAnnotationSpy(annotation);
|
element.addAnnotationSpy(annotation);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ interface IframeClickMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface EventServiceView extends HTMLElement {
|
interface EventServiceView extends HTMLElement {
|
||||||
|
isFixedLayout: boolean;
|
||||||
addAnnotation(annotation: { value: string }): void;
|
addAnnotation(annotation: { value: string }): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +426,7 @@ export class ReaderEventService {
|
|||||||
const deltaX = touch.clientX - this.touchStartX;
|
const deltaX = touch.clientX - this.touchStartX;
|
||||||
const deltaY = Math.abs(touch.clientY - this.touchStartY);
|
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;
|
if (this.isNavigating) return;
|
||||||
|
|
||||||
this.isNavigating = true;
|
this.isNavigating = true;
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ interface FoliateSearchSectionResult {
|
|||||||
type FoliateSearchResult = FoliateSearchProgress | FoliateSearchSectionResult | 'done';
|
type FoliateSearchResult = FoliateSearchProgress | FoliateSearchSectionResult | 'done';
|
||||||
|
|
||||||
interface FoliateViewElement extends HTMLElement {
|
interface FoliateViewElement extends HTMLElement {
|
||||||
|
isFixedLayout: boolean;
|
||||||
renderer?: FoliateRenderer | null;
|
renderer?: FoliateRenderer | null;
|
||||||
book?: FoliateBook;
|
book?: FoliateBook;
|
||||||
open(target: File | object): Promise<void>;
|
open(target: File | object): Promise<void>;
|
||||||
|
|||||||
Reference in New Issue
Block a user