@@ -189,6 +189,11 @@ class ReactImageLightbox extends Component {
189
189
190
190
// Change zoom level
191
191
changeZoom ( zoomLevel , clientX , clientY ) {
192
+ // Ignore if zoom disabled
193
+ if ( ! this . props . enableZoom ) {
194
+ return ;
195
+ }
196
+
192
197
// Constrain zoom level to the set bounds
193
198
const nextZoomLevel = Math . max ( MIN_ZOOM_LEVEL , Math . min ( MAX_ZOOM_LEVEL , zoomLevel ) ) ;
194
199
@@ -834,6 +839,7 @@ class ReactImageLightbox extends Component {
834
839
animationDuration,
835
840
clickOutsideToClose,
836
841
discourageDownloads,
842
+ enableZoom,
837
843
imageTitle,
838
844
nextSrc,
839
845
prevSrc,
@@ -1107,23 +1113,27 @@ class ReactImageLightbox extends Component {
1107
1113
< li key = { i } className = { `ril-toolbar__item ${ styles . toolbarItem } ` } > { button } </ li >
1108
1114
) ) }
1109
1115
1110
- < li className = { `ril-toolbar__item ${ styles . toolbarItem } ` } >
1111
- < button // Lightbox zoom in button
1112
- type = "button"
1113
- key = "zoom-in"
1114
- className = { `zoom-in ril-zoom-in ${ zoomInButtonClasses . join ( ' ' ) } ` }
1115
- onClick = { zoomInButtonHandler }
1116
- />
1117
- </ li >
1118
-
1119
- < li className = { `ril-toolbar__item ${ styles . toolbarItem } ` } >
1120
- < button // Lightbox zoom out button
1121
- type = "button"
1122
- key = "zoom-out"
1123
- className = { `zoom-out ril-zoom-out ${ zoomOutButtonClasses . join ( ' ' ) } ` }
1124
- onClick = { zoomOutButtonHandler }
1125
- />
1126
- </ li >
1116
+ { enableZoom &&
1117
+ < li className = { `ril-toolbar__item ${ styles . toolbarItem } ` } >
1118
+ < button // Lightbox zoom in button
1119
+ type = "button"
1120
+ key = "zoom-in"
1121
+ className = { `zoom-in ril-zoom-in ${ zoomInButtonClasses . join ( ' ' ) } ` }
1122
+ onClick = { zoomInButtonHandler }
1123
+ />
1124
+ </ li >
1125
+ }
1126
+
1127
+ { enableZoom &&
1128
+ < li className = { `ril-toolbar__item ${ styles . toolbarItem } ` } >
1129
+ < button // Lightbox zoom out button
1130
+ type = "button"
1131
+ key = "zoom-out"
1132
+ className = { `zoom-out ril-zoom-out ${ zoomOutButtonClasses . join ( ' ' ) } ` }
1133
+ onClick = { zoomOutButtonHandler }
1134
+ />
1135
+ </ li >
1136
+ }
1127
1137
1128
1138
< li className = { `ril-toolbar__item ${ styles . toolbarItem } ` } >
1129
1139
< button // Lightbox close button
@@ -1248,6 +1258,9 @@ ReactImageLightbox.propTypes = {
1248
1258
1249
1259
// When true, clicks outside of the image close the lightbox
1250
1260
clickOutsideToClose : PropTypes . bool ,
1261
+
1262
+ // Set to false to disable zoom functionality and hide zoom buttons
1263
+ enableZoom : PropTypes . bool ,
1251
1264
} ;
1252
1265
1253
1266
ReactImageLightbox . defaultProps = {
@@ -1266,6 +1279,7 @@ ReactImageLightbox.defaultProps = {
1266
1279
reactModalStyle : { } ,
1267
1280
imagePadding : 10 ,
1268
1281
clickOutsideToClose : true ,
1282
+ enableZoom : true ,
1269
1283
} ;
1270
1284
1271
1285
export default ReactImageLightbox ;
0 commit comments