Skip to content

Commit 76fd487

Browse files
authored
Make imageviewer event listeners browser consistent
1 parent 3e0146f commit 76fd487

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎javascript/imageviewer.js‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,15 @@ function setupImageForLightbox(e) {
131131
e.style.cursor = 'pointer';
132132
e.style.userSelect = 'none';
133133

134-
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
135-
136-
// For Firefox, listening on click first switched to next image then shows the lightbox.
137-
// If you know how to fix this without switching to mousedown event, please.
138-
// For other browsers the event is click to make it possiblr to drag picture.
139-
var event = isFirefox ? 'mousedown' : 'click';
140-
141-
e.addEventListener(event, function(evt) {
134+
e.addEventListener('mousedown', function(evt) {
142135
if (evt.button == 1) {
143136
open(evt.target.src);
144137
evt.preventDefault();
145138
return;
146139
}
140+
}, true);
141+
142+
e.addEventListener('click', function(evt) {
147143
if (!opts.js_modal_lightbox || evt.button != 0) return;
148144

149145
modalZoomSet(gradioApp().getElementById('modalImage'), opts.js_modal_lightbox_initially_zoomed);

0 commit comments

Comments
 (0)