Parcourir la source

update:图片点击增加 esc键关闭弹窗v1

lvzhiqiang il y a 1 an
Parent
commit
be3c8460fc
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      src/main/resources/static/js/my-picture.js

+ 12 - 0
src/main/resources/static/js/my-picture.js

@@ -397,4 +397,16 @@ function initContentEvent() {
             $modal.hide();
         }
     });
+
+    $(document).on('keydown', function (event) {
+        if (event.key === "Escape" || event.keyCode === 27) {
+            if ($("#modal").css("display") === 'block') {
+                $("#modal").css("display", "none");
+                $("#modal").find("img").attr("src", "");
+
+                scale = 1;
+                $('#modal-image').css('transform', 'scale(' + scale + ')');
+            }
+        }
+    });
 }