mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-25 04:56:13 +00:00
Compare commits
2 Commits
3755bfde34
...
81c5d8ff46
Author | SHA1 | Date | |
---|---|---|---|
![]() |
81c5d8ff46 | ||
![]() |
a67f5199d3 |
@ -62,20 +62,26 @@ 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();
|
||||||
|
|
||||||
|
// Convert smooth scrolling gestures into discrete notches
|
||||||
|
accumulator += event.deltaY;
|
||||||
|
const threshold = 10;
|
||||||
|
|
||||||
const zoomAPI = window.embedPdfZoom;
|
const zoomAPI = window.embedPdfZoom;
|
||||||
if (zoomAPI) {
|
if (zoomAPI) {
|
||||||
if (event.deltaY < 0) {
|
if (accumulator <= -threshold) {
|
||||||
// Scroll up - zoom in
|
|
||||||
zoomAPI.zoomIn();
|
zoomAPI.zoomIn();
|
||||||
} else {
|
accumulator = 0;
|
||||||
// Scroll down - zoom out
|
} else if (accumulator >= threshold) {
|
||||||
zoomAPI.zoomOut();
|
zoomAPI.zoomOut();
|
||||||
|
accumulator = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,5 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
base: "http://localhost:8080",
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user