Merge pull request #10903 from 2betop/fix-image-gallery

fix: 修复图片放大功能右键也会触发图片移动的问题
This commit is contained in:
hsm-lv 2024-09-18 10:50:48 +08:00 committed by GitHub
commit 8e77ccfa7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -150,6 +150,12 @@ export class ImageGallery extends React.Component<
@autobind
onMouseDown(event: MouseEvent) {
const isLeftButton =
(event.button === 1 && window.event !== null) || event.button === 0;
if (!isLeftButton || event.defaultPrevented) return;
event.preventDefault();
this.galleryMain?.classList.add('is-dragging');
document.body.addEventListener('mousemove', this.onMouseMove);
document.body.addEventListener('mouseup', this.onMouseUp);