@@ -92,20 +92,19 @@ export function PDFJS({
92
92
93
93
const divRef = useRef < HTMLDivElement > ( null ) ;
94
94
95
- // When zoom prop is provided, use onZoom callback to handle pinch gestures
96
- // Otherwise, let usePinchToZoom handle font_size directly
97
- const pinchToZoomConfig = zoom !== undefined && onZoom ? {
95
+ // Configure pinch-to-zoom with appropriate settings
96
+ const pinchToZoomConfig = {
98
97
target : divRef ,
99
- onZoom : ( data ) => {
100
- // Pass the pinch-to-zoom data directly to parent
101
- onZoom ( data ) ;
102
- } ,
103
- getFontSize : ( ) => {
104
- // Convert current zoom back to fontSize for pinch calculations
105
- return zoom * 14 ;
106
- }
107
- } : {
108
- target : divRef
98
+ onZoom : onZoom || ( ( data ) => {
99
+ // Default behavior: set font size directly when no parent callback provided
100
+ actions . set_font_size ( id , data . fontSize ) ;
101
+ } ) ,
102
+ ... ( zoom !== undefined ? {
103
+ getFontSize : ( ) => {
104
+ // Convert current zoom back to fontSize for pinch calculations
105
+ return zoom * 14 ;
106
+ }
107
+ } : { } )
109
108
} ;
110
109
111
110
usePinchToZoom ( pinchToZoomConfig ) ;
@@ -803,6 +802,14 @@ export function PDFJS({
803
802
cursor,
804
803
textAlign : "center" ,
805
804
backgroundColor : ! loaded ? "white" : BG_COL ,
805
+ // Disable browser's native touch behaviors to allow our pinch-to-zoom to work
806
+ touchAction : "none" ,
807
+ WebkitTouchCallout : "none" ,
808
+ WebkitUserSelect : "none" ,
809
+ KhtmlUserSelect : "none" ,
810
+ MozUserSelect : "none" ,
811
+ msUserSelect : "none" ,
812
+ userSelect : "none" ,
806
813
} }
807
814
ref = { divRef }
808
815
onMouseDown = { onMouseDown }
0 commit comments