Merge branch 'feature/v2/embed-pdf' of https://github.com/Stirling-Tools/Stirling-PDF into feature/v2/embed-pdf

This commit is contained in:
Reece Browne 2025-09-16 19:37:50 +01:00
commit b81ed9ec2e
2 changed files with 42 additions and 10 deletions

View File

@ -63,18 +63,36 @@ const EmbedPdfViewerContent = ({
// Handle scroll wheel zoom // Handle scroll wheel zoom
React.useEffect(() => { React.useEffect(() => {
let accumulator = 0;
const handleWheel = (event: WheelEvent) => { const handleWheel = (event: WheelEvent) => {
// Check if Ctrl (Windows/Linux) or Cmd (Mac) is pressed // Check if Ctrl (Windows/Linux) or Cmd (Mac) is pressed
if (event.ctrlKey || event.metaKey) { if (event.ctrlKey || event.metaKey) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
<<<<<<< HEAD
if (event.deltaY < 0) { if (event.deltaY < 0) {
// Scroll up - zoom in // Scroll up - zoom in
zoomActions.zoomIn(); zoomActions.zoomIn();
} else { } else {
// Scroll down - zoom out // Scroll down - zoom out
zoomActions.zoomOut(); zoomActions.zoomOut();
=======
// Convert smooth scrolling gestures into discrete notches
accumulator += event.deltaY;
const threshold = 10;
const zoomAPI = window.embedPdfZoom;
if (zoomAPI) {
if (accumulator <= -threshold) {
zoomAPI.zoomIn();
accumulator = 0;
} else if (accumulator >= threshold) {
zoomAPI.zoomOut();
accumulator = 0;
}
>>>>>>> 81c5d8ff46dcc5fc983109fb2348b6d6dfb129d2
} }
} }
}; };
@ -113,6 +131,17 @@ const EmbedPdfViewerContent = ({
}; };
}, [isViewerHovered]); }, [isViewerHovered]);
<<<<<<< HEAD
=======
// Expose toggle functions globally for right rail buttons
React.useEffect(() => {
window.toggleThumbnailSidebar = toggleThumbnailSidebar;
return () => {
delete window.toggleThumbnailSidebar;
};
}, [toggleThumbnailSidebar]);
>>>>>>> 81c5d8ff46dcc5fc983109fb2348b6d6dfb129d2
return ( return (
<Box <Box
@ -161,7 +190,9 @@ const EmbedPdfViewerContent = ({
flex: 1, flex: 1,
overflow: 'hidden', overflow: 'hidden',
minHeight: 0, minHeight: 0,
minWidth: 0 minWidth: 0,
marginRight: isThumbnailSidebarVisible ? '15rem' : '0',
transition: 'margin-right 0.3s ease'
}}> }}>
<LocalEmbedPDF <LocalEmbedPDF
file={effectiveFile.file} file={effectiveFile.file}

View File

@ -12,4 +12,5 @@ export default defineConfig({
}, },
}, },
}, },
base: "http://localhost:8080",
}); });