mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
Merge branch 'feature/v2/embed-pdf' of https://github.com/Stirling-Tools/Stirling-PDF into feature/v2/embed-pdf
This commit is contained in:
commit
b81ed9ec2e
@ -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,16 +131,27 @@ 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
|
||||||
ref={viewerRef}
|
ref={viewerRef}
|
||||||
onMouseEnter={() => setIsViewerHovered(true)}
|
onMouseEnter={() => setIsViewerHovered(true)}
|
||||||
onMouseLeave={() => setIsViewerHovered(false)}
|
onMouseLeave={() => setIsViewerHovered(false)}
|
||||||
style={{
|
style={{
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
contain: 'layout style paint'
|
contain: 'layout style paint'
|
||||||
@ -156,12 +185,14 @@ const EmbedPdfViewerContent = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* EmbedPDF Viewer */}
|
{/* EmbedPDF Viewer */}
|
||||||
<Box style={{
|
<Box style={{
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
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}
|
||||||
@ -220,4 +251,4 @@ const EmbedPdfViewer = (props: EmbedPdfViewerProps) => {
|
|||||||
return <EmbedPdfViewerContent {...props} />;
|
return <EmbedPdfViewerContent {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EmbedPdfViewer;
|
export default EmbedPdfViewer;
|
||||||
|
@ -12,4 +12,5 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
base: "http://localhost:8080",
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user