+ Zoom only on click
+ Two images: first will zoom on click, second will not.
+
+
+
+
+
+
+
+
+ First
+ Back
+ Next
+ Last
+
+
+);
diff --git a/src/App/examples/Example15/index.js b/src/App/examples/Example15/index.js
new file mode 100644
index 0000000..72cb48f
--- /dev/null
+++ b/src/App/examples/Example15/index.js
@@ -0,0 +1,3 @@
+import Example15 from './Example15';
+
+export default Example15;
diff --git a/src/App/examples/index.js b/src/App/examples/index.js
index f890ea7..a4ff528 100644
--- a/src/App/examples/index.js
+++ b/src/App/examples/index.js
@@ -12,3 +12,4 @@ export { default as Example11 } from './Example11';
export { default as Example12 } from './Example12';
export { default as Example13 } from './Example13';
export { default as Example14 } from './Example14';
+export { default as Example15 } from './Example15';
diff --git a/src/ImageWithZoom/ImageWithZoom.jsx b/src/ImageWithZoom/ImageWithZoom.jsx
index 9784082..1c1bb72 100644
--- a/src/ImageWithZoom/ImageWithZoom.jsx
+++ b/src/ImageWithZoom/ImageWithZoom.jsx
@@ -25,7 +25,8 @@ const ImageWithZoom = class ImageWithZoom extends React.Component {
srcZoomed: PropTypes.string,
tag: PropTypes.string,
isPinchZoomEnabled: PropTypes.bool,
- }
+ onlyZoomOnClick: PropTypes.bool,
+ };
static defaultProps = {
alt: undefined,
@@ -40,7 +41,8 @@ const ImageWithZoom = class ImageWithZoom extends React.Component {
onError: null,
srcZoomed: null,
tag: 'div',
- }
+ onlyZoomOnClick: false,
+ };
/**
* Find the midpoint between two touches.
@@ -86,6 +88,9 @@ const ImageWithZoom = class ImageWithZoom extends React.Component {
// tracks the status via image element's onerror events.
isImageLoadingError: true,
+ // tracks if the user has clicked on the image or not.
+ clicked: false,
+
// the mouse is currently hovering over the image.
isHovering: false,
@@ -156,6 +161,7 @@ const ImageWithZoom = class ImageWithZoom extends React.Component {
if (this.state.isZooming) return;
this.setState({
isHovering: false,
+ clicked: false,
scale: 1,
});
}
@@ -303,6 +309,7 @@ const ImageWithZoom = class ImageWithZoom extends React.Component {
src,
srcZoomed,
tag: Tag,
+ onlyZoomOnClick,
...filteredProps
} = this.props;
@@ -333,8 +340,38 @@ const ImageWithZoom = class ImageWithZoom extends React.Component {
overlayStyle.transform = `scale(${this.state.scale})`;
}
+ const overlayImage = (
+