From 61220a02a1dc2fa9337cd336c3bf4580f05054f7 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Sun, 29 Aug 2021 07:23:52 -0700 Subject: [PATCH] On desktop devices, when reading with fit to width or original, next page would't reset scroll position. (#535) --- API.Benchmark/Program.cs | 2 +- .../manga-reader/manga-reader.component.ts | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/API.Benchmark/Program.cs b/API.Benchmark/Program.cs index 8111eaecc..05c296f8b 100644 --- a/API.Benchmark/Program.cs +++ b/API.Benchmark/Program.cs @@ -8,7 +8,7 @@ namespace API.Benchmark /// then copy the outputted dll /// dotnet copied_string\API.Benchmark.dll /// - public class Program + public static class Program { static void Main(string[] args) { diff --git a/UI/Web/src/app/manga-reader/manga-reader.component.ts b/UI/Web/src/app/manga-reader/manga-reader.component.ts index 4dc6fe371..8e6d8c9b3 100644 --- a/UI/Web/src/app/manga-reader/manga-reader.component.ts +++ b/UI/Web/src/app/manga-reader/manga-reader.component.ts @@ -482,11 +482,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { } getFittingIcon() { - let value = FITTING_OPTION.HEIGHT; - const formControl = this.generalSettingsForm.get('fittingOption'); - if (formControl !== undefined) { - value = formControl?.value; - } + const value = this.getFit(); switch(value) { case FITTING_OPTION.HEIGHT: @@ -498,6 +494,15 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { } } + getFit() { + let value = FITTING_OPTION.HEIGHT; + const formControl = this.generalSettingsForm.get('fittingOption'); + if (formControl !== undefined) { + value = formControl?.value; + } + return value; + } + cancelMenuCloseTimer() { if (this.menuTimeout) { clearTimeout(this.menuTimeout); @@ -735,6 +740,11 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { } else { this.ctx.drawImage(this.canvasImage, 0, 0); } + // Reset scroll on non HEIGHT Fits + if (this.getFit() !== FITTING_OPTION.HEIGHT) { + window.scrollTo(0, 0); + } + } this.isLoading = false; }