mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add magnifier, interaction mode toggle, and zoom percentage display
Magnifier (fixed-layout.js): - Rewrite magnifier to use CSS background-image for comics (blob URLs from iframe img elements) and canvas drawImage for PDFs. Replaces broken iframe.cloneNode approach that created empty sandboxed clones. - Detect which iframe is under the cursor by checking bounding rects, so magnifier works on both left and right panes. - Forward mousemove events from iframe documents to handleMagnifierMove so the magnifier follows the cursor inside iframes. - Add background-repeat: no-repeat to lens styles. - Add zoomMagnifierEnabled getter for external state checks. Interaction mode toggle (PDF only): - Add 'interaction-mode' observed attribute with 'select'/'pan' values. - In select mode (default for PDFs): mouse events pass through for text selection; Shift+drag enables panning as a fallback. - In pan mode: drag-to-pan works as normal. - Comic books always use pan mode (no text to select). - Auto-detect PDF via #isPDF flag set in #showSpread from onZoom presence. - Add isPDF getter so reader.js can show/hide the toggle button. - Add toggle button in reader.html, hidden by default, shown for PDFs via the view 'load' event. - Escape key dismisses the magnifier. Zoom percentage display (reader.js): - Dispatch 'zoom' CustomEvent from #zoomByRatio with the new scale. - Listener in reader.js updates the percentage display on scroll zoom. Also includes minor formatting (line wrapping) in #goLeft/#goRight.
This commit is contained in:
+10
@@ -365,6 +365,16 @@
|
||||
<path d="M 14 14 L 18 18" />
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
id="interaction-mode-toggle"
|
||||
aria-label="Toggle pan/select mode"
|
||||
title="Pan Mode"
|
||||
style="display: none"
|
||||
>
|
||||
<svg class="icon" width="20" height="20" aria-hidden="true">
|
||||
<path d="M 5 9 h 10 M 10 5 v 10" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<script src="reader.js" type="module"></script>
|
||||
|
||||
Reference in New Issue
Block a user