Memory: rendered page canvases were never released, so flipping through a document accumulated one supersampled canvas per page for the lifetime of the page. Measured on a 30-page PDF this reached 174 MB and stayed there; the figure grows linearly with page count, which puts a mid-sized catalogue past what a mobile browser will tolerate. Pages outside a window around the current spread now have their canvas released (dimensions zeroed so the backing store goes immediately) and their placeholder restored. Same document now plateaus at 64 MB regardless of reading position. Supersampling was pinned at 2x even on 1x displays, which costs four times the memory of a 1x canvas for no visible gain there. It now follows the device pixel ratio between 1.5x and 2x. Startup: buildPageDescriptors() walked the entire document calling getPage() on every page, including when spread splitting was disabled -- the default. On long PDFs that is hundreds of sequential PDF.js round trips before the first paint. The walk now happens only when splitting is actually on. Rendering races: a resize landing while a page was rasterising left that page with a canvas sized for the previous layout, marked as rendered and therefore never corrected. Renders now carry a generation stamp and are discarded if the layout moved underneath them, and the in-flight task is cancelled rather than left to finish work that is already void. Not reproduced from outside -- the window is narrow -- but the sequence is plain in the code. Deployment: asset URLs were absolute from the web root, so the bundle broke whenever Contao ran in a subdirectory. They now derive from import.meta.url. Verified under /kunde/shop/ with no failed requests. Assets moved from the template into the controller via TL_HEAD, keyed so several flipbooks on one page emit one copy each, in the head rather than after the content. Also: - Front-end strings were hardcoded German despite the bundle shipping de/en. They now come from TL_LANG and reach the module as data attributes. - Swallowed errors now reach the console; a failing PDF left no trace before. - Canvas text is invisible to assistive technology: pages carry aria-labels and the source PDF is offered as an equivalent download. Honours reduced motion. - No teardown existed; destroy() plus a MummertPdfFlipbook API for AJAX pages. - Pages deviating from the document's dominant format were stretched. The layout ratio is now the median of a leading sample, with object-fit: contain. - Aspect ratio, pointerdown stealing focus from buttons, single Audio element cutting itself off on fast flips. - Vendored PDF.js cmaps and standard fonts: without them, PDFs using CID encodings or relying on the base-14 fonts render blank. - Dropped pdf.min.mjs and pdf.worker.min.mjs -- byte-identical copies of the .js files that nothing referenced (1.7 MB). - Third-party licence texts were referenced but never shipped. Added, including the separate Foxit and Liberation terms that come with the fonts. Recorded that flipbook-js publishes no LICENSE file upstream. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
20 lines
1.2 KiB
PHP
20 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$GLOBALS['TL_LANG']['CTE']['blatterbares_pdf'] = ['Blätterbares PDF', 'Zeigt ein PDF als blätterbares Flipbook mit Lazy-Rendering an.'];
|
|
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookRegionLabel'] = 'Blätterbares PDF';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookLoading'] = 'PDF wird geladen ...';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookError'] = 'PDF konnte nicht geladen werden.';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookMissing'] = 'Keine PDF-Datei gefunden.';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookNotConfigured'] = 'Keine PDF-Datei konfiguriert.';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookNotPublic'] = 'Die gewählte PDF-Datei liegt in einem geschützten Ordner und ist im Frontend nicht abrufbar.';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookRendering'] = 'Seite {page} wird gerendert ...';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookBlank'] = 'Leere Seite';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookPageLabel'] = 'Seite {page} von {total}';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookNavLabel'] = 'Flipbook-Navigation';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookPrev'] = 'Zurück';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookNext'] = 'Weiter';
|
|
$GLOBALS['TL_LANG']['MSC']['flipbookDownload'] = 'PDF herunterladen';
|