New reader testing
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<link rel="manifest" crossorigin="use-credentials" href="manifest.json" />
|
<link rel="manifest" crossorigin="use-credentials" href="manifest.json" />
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, height=device-height,initial-scale=1, minimum-scale=1, user-scalable=no"
|
content="width=device-width, height=device-height,initial-scale=1, minimum-scale=1"
|
||||||
/>
|
/>
|
||||||
<script src="https://apis.google.com/js/api.js"></script>
|
<script src="https://apis.google.com/js/api.js"></script>
|
||||||
<script src="https://accounts.google.com/gsi/client"></script>
|
<script src="https://accounts.google.com/gsi/client"></script>
|
||||||
|
|||||||
@@ -35,10 +35,17 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
draggable="false"
|
draggable="false"
|
||||||
style:width={`${page.img_width}px`}
|
style:width={`${window.innerWidth}px`}
|
||||||
style:height={`${page.img_height}px`}
|
style:height={`${(window.innerWidth * page.img_height) / page.img_width}px`}
|
||||||
style:background-image={url}
|
style:background-image={url}
|
||||||
class="relative"
|
class="relative"
|
||||||
>
|
>
|
||||||
<TextBoxes {page} {src} />
|
<TextBoxes {page} {src} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
background-size: contain;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -9,15 +9,20 @@
|
|||||||
|
|
||||||
$: textBoxes = page.blocks
|
$: textBoxes = page.blocks
|
||||||
.map((block) => {
|
.map((block) => {
|
||||||
const { img_height, img_width } = page;
|
const { img_height: imgh, img_width: imgw } = page;
|
||||||
|
const img_height = (window.innerWidth * imgh) / imgw;
|
||||||
|
const img_width = window.innerWidth;
|
||||||
const { box, font_size, lines, vertical } = block;
|
const { box, font_size, lines, vertical } = block;
|
||||||
|
|
||||||
let [_xmin, _ymin, _xmax, _ymax] = box;
|
const resizeFactor = window.innerWidth / imgw;
|
||||||
|
|
||||||
const xmin = clamp(_xmin, 0, img_width);
|
let [_xmin, _ymin, _xmax, _ymax] = box;
|
||||||
const ymin = clamp(_ymin, 0, img_height);
|
console.log(box);
|
||||||
const xmax = clamp(_xmax, 0, img_width);
|
|
||||||
const ymax = clamp(_ymax, 0, img_height);
|
const xmin = clamp(_xmin * resizeFactor, 0, img_width);
|
||||||
|
const ymin = clamp(_ymin * resizeFactor, 0, img_height);
|
||||||
|
const xmax = clamp(_xmax * resizeFactor, 0, img_width);
|
||||||
|
const ymax = clamp(_ymax * resizeFactor, 0, img_height);
|
||||||
|
|
||||||
const width = xmax - xmin;
|
const width = xmax - xmin;
|
||||||
const height = ymax - ymin;
|
const height = ymax - ymin;
|
||||||
|
|||||||
26
src/lib/components/ReaderV2/ReaderV2.svelte
Normal file
26
src/lib/components/ReaderV2/ReaderV2.svelte
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { volume } from '$lib/catalog';
|
||||||
|
import MangaPage from '../Reader/MangaPage.svelte';
|
||||||
|
|
||||||
|
$: files = $volume ? Object.values($volume?.files).slice(0, 10) : [];
|
||||||
|
$: pages = $volume?.mokuroData?.pages || [];
|
||||||
|
|
||||||
|
$: {
|
||||||
|
const { innerWidth, innerHeight } = window;
|
||||||
|
console.log(innerWidth, innerHeight);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
{#each files as file, i}
|
||||||
|
<MangaPage src={file} page={pages[i]} />
|
||||||
|
{/each}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
$: zoomModeValue = $settings.zoomDefault;
|
$: zoomModeValue = $settings.zoomDefault;
|
||||||
$: fontSizeValue = $settings.fontSize;
|
$: fontSizeValue = $settings.fontSize;
|
||||||
|
$: readerValue = $settings.reader || 'classic';
|
||||||
|
|
||||||
|
let readers = [
|
||||||
|
{ value: 'classic', name: 'Classic' },
|
||||||
|
{ value: 'v2', name: 'V2' }
|
||||||
|
];
|
||||||
|
|
||||||
let zoomModes = [
|
let zoomModes = [
|
||||||
{ value: 'zoomFitToScreen', name: 'Fit to screen' },
|
{ value: 'zoomFitToScreen', name: 'Fit to screen' },
|
||||||
@@ -40,6 +46,11 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Label>Reader:</Label>
|
||||||
|
<Select items={readers} value={readerValue} on:change={(e) => onSelectChange(e, 'reader')} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label>On page zoom:</Label>
|
<Label>On page zoom:</Label>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export const READER_VERSION = '0.9.0'
|
export const READER_VERSION = '1.0.0'
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { derived, get, writable } from 'svelte/store';
|
import { derived, get, writable } from 'svelte/store';
|
||||||
|
|
||||||
|
export type Readers = 'classic' | 'v2'
|
||||||
|
|
||||||
export type FontSize =
|
export type FontSize =
|
||||||
| 'auto'
|
| 'auto'
|
||||||
| '9'
|
| '9'
|
||||||
@@ -41,6 +43,7 @@ export type VolumeDefaults = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
|
reader: Readers,
|
||||||
textEditable: boolean;
|
textEditable: boolean;
|
||||||
textBoxBorders: boolean;
|
textBoxBorders: boolean;
|
||||||
displayOCR: boolean;
|
displayOCR: boolean;
|
||||||
@@ -67,6 +70,7 @@ export type AnkiSettingsKey = keyof AnkiConnectSettings;
|
|||||||
export type VolumeDefaultsKey = keyof VolumeDefaults;
|
export type VolumeDefaultsKey = keyof VolumeDefaults;
|
||||||
|
|
||||||
const defaultSettings: Settings = {
|
const defaultSettings: Settings = {
|
||||||
|
reader: 'classic',
|
||||||
displayOCR: true,
|
displayOCR: true,
|
||||||
textEditable: false,
|
textEditable: false,
|
||||||
textBoxBorders: false,
|
textBoxBorders: false,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:global(body.reader) {
|
/* :global(body.reader) {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
}
|
} */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import Timer from '$lib/components/Reader/Timer.svelte';
|
import Timer from '$lib/components/Reader/Timer.svelte';
|
||||||
import { initializeVolume, settings, startCount, volumeSettings, volumes } from '$lib/settings';
|
import { initializeVolume, settings, startCount, volumeSettings, volumes } from '$lib/settings';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import ReaderV2 from '$lib/components/ReaderV2/ReaderV2.svelte';
|
||||||
|
|
||||||
const volumeId = $page.params.volume;
|
const volumeId = $page.params.volume;
|
||||||
let count: undefined | number = undefined;
|
let count: undefined | number = undefined;
|
||||||
@@ -26,5 +27,9 @@
|
|||||||
{#if $settings.showTimer}
|
{#if $settings.showTimer}
|
||||||
<Timer bind:count {volumeId} />
|
<Timer bind:count {volumeId} />
|
||||||
{/if}
|
{/if}
|
||||||
<Reader volumeSettings={$volumeSettings[volumeId]} />
|
{#if $settings.reader === 'classic'}
|
||||||
|
<Reader volumeSettings={$volumeSettings[volumeId]} />
|
||||||
|
{:else}
|
||||||
|
<ReaderV2 />
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user