From e523b1b57afcd90725b36a92d1aa460911a6d3ba Mon Sep 17 00:00:00 2001 From: mmarkelov Date: Wed, 14 Jul 2021 23:09:21 +0300 Subject: [PATCH] New discourageDownloads --- src/react-image-lightbox.js | 48 ++++++++++++++----------------------- src/style.css | 16 ------------- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/react-image-lightbox.js b/src/react-image-lightbox.js index ff8b2d7f..44d8862d 100644 --- a/src/react-image-lightbox.js +++ b/src/react-image-lightbox.js @@ -1377,37 +1377,25 @@ class ReactImageLightbox extends Component { } const imageSrc = bestImageInfo.src; - if (discourageDownloads) { - imageStyle.backgroundImage = `url('${imageSrc}')`; - images.push( -
-
-
- ); - } else { - images.push( - e.preventDefault()} - style={imageStyle} - src={imageSrc} - key={imageSrc + keyEndings[srcType]} - alt={ - typeof imageTitle === 'string' ? imageTitle : translate('Image') + images.push( + { + if (discourageDownloads) { + e.preventDefault(); } - draggable={false} - /> - ); - } + }} + onWheel={this.handleImageMouseWheel} + onDragStart={e => e.preventDefault()} + style={imageStyle} + src={imageSrc} + key={imageSrc + keyEndings[srcType]} + alt={typeof imageTitle === 'string' ? imageTitle : translate('Image')} + draggable={false} + /> + ); }; const zoomMultiplier = this.getZoomMultiplier(); diff --git a/src/style.css b/src/style.css index 9c4dfa3c..27a618fb 100644 --- a/src/style.css +++ b/src/style.css @@ -51,12 +51,6 @@ touch-action: none; } -.ril__imageDiscourager { - background-repeat: no-repeat; - background-position: center; - background-size: contain; -} - .ril__navButtons { border: none; position: absolute; @@ -90,16 +84,6 @@ no-repeat center; } -.ril__downloadBlocker { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-image: url('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'); - background-size: cover; -} - .ril__caption, .ril__toolbar { background-color: rgba(0, 0, 0, 0.5);