@@ -55,13 +55,13 @@ const defaultBodyAttrs: BodyAttrs = {
5555export interface ControlledProps {
5656 a11yNameButtonUnzoom ?: string
5757 a11yNameButtonZoom ?: string
58+ canSwipeToUnzoom ?: boolean
5859 children : React . ReactNode
5960 classDialog ?: string
6061 IconUnzoom ?: React . ElementType
6162 IconZoom ?: React . ElementType
6263 isZoomed : boolean
6364 onZoomChange ?: ( value : boolean ) => void
64- canSwipeToUnzoom ?: boolean
6565 swipeToUnzoomThreshold ?: number
6666 wrapElement ?: 'div' | 'span'
6767 ZoomContent ?: ( data : {
@@ -82,9 +82,9 @@ interface ControlledDefaultProps {
8282 a11yNameButtonUnzoom : string
8383 a11yNameButtonZoom : string
8484 canSwipeToUnzoom : boolean
85- swipeToUnzoomThreshold : number
8685 IconUnzoom : React . ElementType
8786 IconZoom : React . ElementType
87+ swipeToUnzoomThreshold : number
8888 wrapElement : 'div' | 'span'
8989 zoomMargin : number
9090}
@@ -103,9 +103,9 @@ class ControlledBase extends React.Component<ControlledPropsWithDefaults, Contro
103103 static defaultProps : ControlledDefaultProps = {
104104 a11yNameButtonUnzoom : 'Minimize image' ,
105105 a11yNameButtonZoom : 'Expand image' ,
106+ canSwipeToUnzoom : true ,
106107 IconUnzoom : ICompress ,
107108 IconZoom : IEnlarge ,
108- canSwipeToUnzoom : true ,
109109 swipeToUnzoomThreshold : 10 ,
110110 wrapElement : 'div' ,
111111 zoomMargin : 0 ,
@@ -549,21 +549,21 @@ class ControlledBase extends React.Component<ControlledPropsWithDefaults, Contro
549549 * and unzoom if we detect a swipe
550550 */
551551 handleTouchMove = ( e : TouchEvent ) => {
552- if ( ! this . props . canSwipeToUnzoom ) {
553- return
554- }
555-
556552 const browserScale = window . visualViewport ?. scale ?? 1
557553
558- if ( ! this . isScaling && browserScale <= 1 && this . touchYStart != null && e . changedTouches [ 0 ] ) {
554+ if (
555+ this . props . canSwipeToUnzoom &&
556+ ! this . isScaling &&
557+ browserScale <= 1 && this . touchYStart != null &&
558+ e . changedTouches [ 0 ]
559+ ) {
559560 this . touchYEnd = e . changedTouches [ 0 ] . screenY
560561
561562 const max = Math . max ( this . touchYStart , this . touchYEnd )
562563 const min = Math . min ( this . touchYStart , this . touchYEnd )
563564 const delta = Math . abs ( max - min )
564- const { swipeToUnzoomThreshold } = this . props
565565
566- if ( delta > swipeToUnzoomThreshold ) {
566+ if ( delta > this . props . swipeToUnzoomThreshold ) {
567567 this . touchYStart = undefined
568568 this . touchYEnd = undefined
569569 this . handleUnzoom ( )
0 commit comments