2026-09-23-attachment-image-preview-rotate-demo.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>附件图片预览 · 左转 / 右转 Demo</title>
  7. <link rel="preconnect" href="https://fonts.googleapis.com" />
  8. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  9. <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
  10. <style>
  11. :root {
  12. --primary: #10b981;
  13. --primary-dark: #059669;
  14. --primary-bg: #ecfdf5;
  15. --text: #1e293b;
  16. --text-muted: #64748b;
  17. --border: #d9e8e2;
  18. --bg-page: #f8fafc;
  19. --surface: #ffffff;
  20. --radius: 10px;
  21. --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  22. }
  23. * { box-sizing: border-box; margin: 0; padding: 0; }
  24. body {
  25. min-height: 100vh;
  26. font-family: Inter, -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
  27. font-size: 14px;
  28. line-height: 1.5;
  29. color: var(--text);
  30. background: var(--bg-page);
  31. padding: 28px 20px 48px;
  32. }
  33. .page {
  34. max-width: 920px;
  35. margin: 0 auto;
  36. }
  37. .intro h1 {
  38. font-size: 18px;
  39. font-weight: 700;
  40. margin-bottom: 6px;
  41. }
  42. .intro p {
  43. font-size: 13px;
  44. color: var(--text-muted);
  45. margin-bottom: 4px;
  46. }
  47. .intro code {
  48. font-size: 12px;
  49. background: #fff;
  50. border: 1px solid #cbd5e1;
  51. border-radius: 4px;
  52. padding: 1px 6px;
  53. }
  54. .legend {
  55. display: flex;
  56. flex-wrap: wrap;
  57. gap: 8px;
  58. margin: 14px 0 20px;
  59. }
  60. .legend span {
  61. font-size: 12px;
  62. background: #fff;
  63. border: 1px solid #cbd5e1;
  64. border-radius: 999px;
  65. padding: 4px 10px;
  66. color: #475569;
  67. }
  68. .panel {
  69. background: var(--surface);
  70. border: 1px solid var(--border);
  71. border-radius: var(--radius);
  72. box-shadow: var(--shadow);
  73. padding: 20px;
  74. }
  75. .panel-top {
  76. margin-bottom: 14px;
  77. }
  78. .panel-top h2 {
  79. position: relative;
  80. display: inline-flex;
  81. align-items: center;
  82. gap: 8px;
  83. font-size: 15px;
  84. font-weight: 600;
  85. padding-left: 10px;
  86. }
  87. .panel-top h2::before {
  88. content: '';
  89. position: absolute;
  90. left: 0;
  91. top: 2px;
  92. bottom: 2px;
  93. width: 3px;
  94. border-radius: 2px;
  95. background: var(--primary);
  96. }
  97. .panel-tip {
  98. margin-top: 6px;
  99. font-size: 12px;
  100. color: var(--text-muted);
  101. }
  102. .attachment-list {
  103. display: flex;
  104. flex-wrap: wrap;
  105. gap: 12px;
  106. align-items: flex-start;
  107. }
  108. .upload-card {
  109. width: 140px;
  110. height: 96px;
  111. border: 1px dashed #a7f3d0;
  112. background: #f0fdf4;
  113. border-radius: 8px;
  114. display: flex;
  115. flex-direction: column;
  116. align-items: center;
  117. justify-content: center;
  118. gap: 6px;
  119. color: var(--primary);
  120. font-size: 12px;
  121. font-weight: 500;
  122. cursor: default;
  123. user-select: none;
  124. }
  125. .upload-card .plus {
  126. font-size: 28px;
  127. line-height: 1;
  128. font-weight: 400;
  129. }
  130. .attachment-item {
  131. width: 140px;
  132. }
  133. .attachment-preview {
  134. width: 140px;
  135. height: 96px;
  136. border: 1px solid var(--border);
  137. border-radius: 8px;
  138. overflow: hidden;
  139. background: #f8fafc;
  140. cursor: pointer;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. }
  145. .attachment-preview:hover {
  146. border-color: var(--primary);
  147. }
  148. .attachment-preview img {
  149. width: 100%;
  150. height: 100%;
  151. object-fit: cover;
  152. display: block;
  153. }
  154. .attachment-preview.is-doc {
  155. flex-direction: column;
  156. gap: 4px;
  157. color: var(--text-muted);
  158. font-size: 12px;
  159. cursor: default;
  160. }
  161. .attachment-name {
  162. display: block;
  163. margin-top: 6px;
  164. font-size: 12px;
  165. color: var(--text);
  166. overflow: hidden;
  167. text-overflow: ellipsis;
  168. white-space: nowrap;
  169. }
  170. /* 预览弹窗 */
  171. .mask {
  172. display: none;
  173. position: fixed;
  174. inset: 0;
  175. background: rgba(15, 23, 42, 0.45);
  176. backdrop-filter: none;
  177. z-index: 1000;
  178. align-items: center;
  179. justify-content: center;
  180. padding: 24px;
  181. }
  182. .mask.show { display: flex; }
  183. .dialog {
  184. width: min(860px, 100%);
  185. background: #fff;
  186. border-radius: 10px;
  187. box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  188. overflow: hidden;
  189. display: flex;
  190. flex-direction: column;
  191. max-height: calc(100vh - 48px);
  192. }
  193. .dialog-header {
  194. display: flex;
  195. align-items: center;
  196. justify-content: space-between;
  197. gap: 12px;
  198. padding: 14px 18px;
  199. border-bottom: 1px solid var(--border);
  200. }
  201. .dialog-title {
  202. font-size: 15px;
  203. font-weight: 600;
  204. overflow: hidden;
  205. text-overflow: ellipsis;
  206. white-space: nowrap;
  207. }
  208. .dialog-close {
  209. width: 28px;
  210. height: 28px;
  211. border: none;
  212. background: transparent;
  213. border-radius: 6px;
  214. color: var(--text-muted);
  215. font-size: 18px;
  216. cursor: pointer;
  217. line-height: 1;
  218. }
  219. .dialog-close:hover {
  220. background: #f1f5f9;
  221. color: var(--text);
  222. }
  223. .dialog-body {
  224. padding: 16px 18px 18px;
  225. overflow: auto;
  226. }
  227. .preview-toolbar {
  228. display: flex;
  229. flex-wrap: wrap;
  230. align-items: center;
  231. justify-content: center;
  232. gap: 8px;
  233. margin-bottom: 12px;
  234. }
  235. .toolbar-sep {
  236. width: 1px;
  237. height: 20px;
  238. background: var(--border);
  239. margin: 0 4px;
  240. }
  241. .btn {
  242. display: inline-flex;
  243. align-items: center;
  244. gap: 6px;
  245. height: 36px;
  246. padding: 0 14px;
  247. border-radius: 8px;
  248. border: 1px solid var(--border);
  249. background: #fff;
  250. color: var(--text);
  251. font-size: 13px;
  252. font-weight: 500;
  253. cursor: pointer;
  254. font-family: inherit;
  255. }
  256. .btn:hover {
  257. border-color: var(--primary);
  258. color: var(--primary-dark);
  259. background: var(--primary-bg);
  260. }
  261. .btn:active { transform: translateY(1px); }
  262. .btn:disabled {
  263. opacity: 0.45;
  264. cursor: not-allowed;
  265. pointer-events: none;
  266. }
  267. .btn svg {
  268. width: 16px;
  269. height: 16px;
  270. flex-shrink: 0;
  271. }
  272. .status-chip {
  273. min-width: 108px;
  274. text-align: center;
  275. font-size: 12px;
  276. color: var(--text-muted);
  277. font-variant-numeric: tabular-nums;
  278. }
  279. .preview-stage {
  280. height: min(62vh, 520px);
  281. min-height: 320px;
  282. background: #f8fafc;
  283. border: 1px solid var(--border);
  284. border-radius: 8px;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. overflow: hidden;
  289. padding: 16px;
  290. cursor: grab;
  291. touch-action: none;
  292. }
  293. .preview-stage.is-dragging {
  294. cursor: grabbing;
  295. }
  296. .preview-stage img {
  297. width: auto;
  298. height: auto;
  299. max-width: none;
  300. max-height: none;
  301. border-radius: 4px;
  302. transition: transform 0.15s ease;
  303. transform-origin: center center;
  304. user-select: none;
  305. -webkit-user-drag: none;
  306. will-change: transform;
  307. pointer-events: none;
  308. }
  309. .preview-stage.is-zooming img,
  310. .preview-stage.is-dragging img {
  311. transition: none;
  312. }
  313. .note {
  314. margin-top: 16px;
  315. padding: 12px 14px;
  316. background: var(--primary-bg);
  317. border: 1px solid #a7f3d0;
  318. border-radius: 8px;
  319. font-size: 12px;
  320. color: #065f46;
  321. }
  322. .note strong { font-weight: 600; }
  323. </style>
  324. </head>
  325. <body>
  326. <div class="page">
  327. <div class="intro">
  328. <h1>附件图片预览 · 旋转 + 缩放</h1>
  329. <p>对齐 <code>AttachmentUploadField</code>:缩略图点击打开预览弹窗;仅图片显示工具条。</p>
  330. <p>交互:左转 / 右转 · 放大 / 缩小 / 重置 · 滚轮缩放 · 拖拽平移 · 关闭后重置。</p>
  331. <p><strong>完整可见:</strong>缩放倍率 = 1 时,旋转后按外接矩形完整装入预览区;放大后可拖拽查看细节。</p>
  332. <div class="legend">
  333. <span>Fresh Mint · #10b981</span>
  334. <span>弹窗 860px</span>
  335. <span>滚轮缩放</span>
  336. <span>仅预览态(不写回文件)</span>
  337. </div>
  338. </div>
  339. <div class="panel">
  340. <div class="panel-top">
  341. <h2>协议附件(示意)</h2>
  342. <p class="panel-tip">点击下方图片缩略图体验预览旋转;PDF 卡片不可预览旋转。</p>
  343. </div>
  344. <div class="attachment-list">
  345. <div class="upload-card" title="示意:正式页为上传入口">
  346. <span class="plus">+</span>
  347. <span>上传附件</span>
  348. </div>
  349. <div class="attachment-item">
  350. <div class="attachment-preview" id="thumb-a" title="点击预览">
  351. <img id="thumb-a-img" alt="现场照片-01.jpg" />
  352. </div>
  353. <span class="attachment-name">现场照片-01.jpg</span>
  354. </div>
  355. <div class="attachment-item">
  356. <div class="attachment-preview" id="thumb-b" title="点击预览">
  357. <img id="thumb-b-img" alt="证件扫描.jpg" />
  358. </div>
  359. <span class="attachment-name">证件扫描.jpg</span>
  360. </div>
  361. <div class="attachment-item">
  362. <div class="attachment-preview is-doc" title="文档:本 Demo 不演示旋转">
  363. <span style="font-size:22px">📄</span>
  364. <span>PDF</span>
  365. </div>
  366. <span class="attachment-name">协议正文.pdf</span>
  367. </div>
  368. </div>
  369. <div class="note">
  370. <strong>推荐落点:</strong>工具条 = 左转 / 右转 · 缩小 / 放大 / 重置;
  371. 预览区滚轮缩放 + 按住拖拽平移。
  372. 倍率 1 = 完整装入。全部仅预览态,不改 MinIO 原文件。
  373. </div>
  374. </div>
  375. </div>
  376. <div class="mask" id="mask" role="dialog" aria-modal="true" aria-labelledby="dialog-title">
  377. <div class="dialog">
  378. <div class="dialog-header">
  379. <div class="dialog-title" id="dialog-title">附件预览</div>
  380. <button type="button" class="dialog-close" id="btn-close" aria-label="关闭">×</button>
  381. </div>
  382. <div class="dialog-body">
  383. <div class="preview-toolbar">
  384. <button type="button" class="btn" id="btn-left" title="逆时针 90°">
  385. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
  386. <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
  387. <path d="M3 3v5h5" />
  388. </svg>
  389. 左转
  390. </button>
  391. <button type="button" class="btn" id="btn-right" title="顺时针 90°">
  392. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
  393. <path d="M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
  394. <path d="M21 3v5h-5" />
  395. </svg>
  396. 右转
  397. </button>
  398. <span class="toolbar-sep" aria-hidden="true"></span>
  399. <button type="button" class="btn" id="btn-zoom-out" title="缩小">
  400. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
  401. <circle cx="11" cy="11" r="7" />
  402. <path d="M21 21l-4.3-4.3M8 11h6" />
  403. </svg>
  404. 缩小
  405. </button>
  406. <button type="button" class="btn" id="btn-zoom-in" title="放大">
  407. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
  408. <circle cx="11" cy="11" r="7" />
  409. <path d="M21 21l-4.3-4.3M11 8v6M8 11h6" />
  410. </svg>
  411. 放大
  412. </button>
  413. <button type="button" class="btn" id="btn-zoom-reset" title="重置为完整可见">
  414. 重置
  415. </button>
  416. <span class="status-chip" id="status-chip">0° · 100%</span>
  417. </div>
  418. <div class="preview-stage" id="preview-stage" title="滚轮缩放 · 按住拖拽平移">
  419. <img id="preview-img" alt="预览" />
  420. </div>
  421. </div>
  422. </div>
  423. </div>
  424. <script>
  425. /** 生成带方向标记的示意图(无需外网) */
  426. function makeDemoImage(label, hue, w, h) {
  427. const svg =
  428. `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}">` +
  429. `<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">` +
  430. `<stop stop-color="hsl(${hue},45%,88%)"/><stop offset="1" stop-color="hsl(${hue},40%,72%)"/>` +
  431. `</linearGradient></defs>` +
  432. `<rect width="100%" height="100%" fill="url(#g)"/>` +
  433. `<rect x="24" y="24" width="120" height="36" rx="6" fill="#059669"/>` +
  434. `<text x="36" y="48" fill="#fff" font-size="16" font-family="Inter,sans-serif" font-weight="600">TOP</text>` +
  435. `<text x="${w / 2}" y="${h / 2}" text-anchor="middle" fill="#1e293b" font-size="28" font-family="Inter,sans-serif" font-weight="600">${label}</text>` +
  436. `<text x="${w / 2}" y="${h / 2 + 36}" text-anchor="middle" fill="#64748b" font-size="14" font-family="Inter,sans-serif">${w}×${h} · 旋转 · 滚轮 · 拖拽</text>` +
  437. `<polygon points="${w / 2 - 16},${h - 56} ${w / 2 + 16},${h - 56} ${w / 2},${h - 28}" fill="#059669"/>` +
  438. `<text x="${w / 2}" y="${h - 12}" text-anchor="middle" fill="#059669" font-size="12" font-family="Inter,sans-serif">BOTTOM</text>` +
  439. `</svg>`
  440. return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg)
  441. }
  442. const files = {
  443. a: { name: '现场照片-01.jpg', src: makeDemoImage('宽图现场照 A', 150, 960, 360) },
  444. b: { name: '证件扫描.jpg', src: makeDemoImage('竖图证件 B', 175, 420, 640) }
  445. }
  446. document.getElementById('thumb-a-img').src = files.a.src
  447. document.getElementById('thumb-b-img').src = files.b.src
  448. const ZOOM_MIN = 0.5
  449. const ZOOM_MAX = 5
  450. const ZOOM_STEP = 0.15
  451. const mask = document.getElementById('mask')
  452. const stage = document.getElementById('preview-stage')
  453. const previewImg = document.getElementById('preview-img')
  454. const dialogTitle = document.getElementById('dialog-title')
  455. const statusChip = document.getElementById('status-chip')
  456. const btnZoomOut = document.getElementById('btn-zoom-out')
  457. const btnZoomIn = document.getElementById('btn-zoom-in')
  458. let angle = 0
  459. /** 相对「完整装入」的倍率:1 = 旋转后整图可见 */
  460. let zoom = 1
  461. let offsetX = 0
  462. let offsetY = 0
  463. let dragging = false
  464. let dragStartX = 0
  465. let dragStartY = 0
  466. let dragOriginX = 0
  467. let dragOriginY = 0
  468. function clampZoom(v) {
  469. return Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, Math.round(v * 100) / 100))
  470. }
  471. function fitBaseScale() {
  472. const padX = 32
  473. const padY = 32
  474. const stageW = Math.max(stage.clientWidth - padX, 1)
  475. const stageH = Math.max(stage.clientHeight - padY, 1)
  476. const natW = previewImg.naturalWidth || 1
  477. const natH = previewImg.naturalHeight || 1
  478. const rad = (angle * Math.PI) / 180
  479. const cos = Math.abs(Math.cos(rad))
  480. const sin = Math.abs(Math.sin(rad))
  481. const boundW = natW * cos + natH * sin
  482. const boundH = natW * sin + natH * cos
  483. return Math.min(stageW / boundW, stageH / boundH)
  484. }
  485. function applyTransform() {
  486. const natW = previewImg.naturalWidth || 1
  487. const natH = previewImg.naturalHeight || 1
  488. const base = fitBaseScale()
  489. const scale = base * zoom
  490. previewImg.style.width = natW + 'px'
  491. previewImg.style.height = natH + 'px'
  492. previewImg.style.transform =
  493. 'translate(' + offsetX + 'px,' + offsetY + 'px) rotate(' + angle + 'deg) scale(' + scale + ')'
  494. const deg = ((angle % 360) + 360) % 360
  495. statusChip.textContent = deg + '° · ' + Math.round(zoom * 100) + '%'
  496. btnZoomOut.disabled = zoom <= ZOOM_MIN
  497. btnZoomIn.disabled = zoom >= ZOOM_MAX
  498. }
  499. function resetView(keepAngle) {
  500. if (!keepAngle) angle = 0
  501. zoom = 1
  502. offsetX = 0
  503. offsetY = 0
  504. applyTransform()
  505. }
  506. function setZoom(next, fromWheel) {
  507. zoom = clampZoom(next)
  508. if (zoom <= 1) {
  509. offsetX = 0
  510. offsetY = 0
  511. }
  512. if (fromWheel) stage.classList.add('is-zooming')
  513. applyTransform()
  514. if (fromWheel) {
  515. requestAnimationFrame(function () {
  516. stage.classList.remove('is-zooming')
  517. })
  518. }
  519. }
  520. function openPreview(key) {
  521. const file = files[key]
  522. dialogTitle.textContent = file.name
  523. angle = 0
  524. zoom = 1
  525. offsetX = 0
  526. offsetY = 0
  527. mask.classList.add('show')
  528. previewImg.onload = function () {
  529. applyTransform()
  530. }
  531. previewImg.src = file.src
  532. if (previewImg.complete) applyTransform()
  533. }
  534. function closePreview() {
  535. mask.classList.remove('show')
  536. angle = 0
  537. zoom = 1
  538. offsetX = 0
  539. offsetY = 0
  540. previewImg.style.transform = ''
  541. statusChip.textContent = '0° · 100%'
  542. }
  543. document.getElementById('thumb-a').addEventListener('click', function () { openPreview('a') })
  544. document.getElementById('thumb-b').addEventListener('click', function () { openPreview('b') })
  545. document.getElementById('btn-close').addEventListener('click', closePreview)
  546. document.getElementById('btn-left').addEventListener('click', function () {
  547. angle -= 90
  548. applyTransform()
  549. })
  550. document.getElementById('btn-right').addEventListener('click', function () {
  551. angle += 90
  552. applyTransform()
  553. })
  554. btnZoomOut.addEventListener('click', function () {
  555. setZoom(zoom - ZOOM_STEP)
  556. })
  557. btnZoomIn.addEventListener('click', function () {
  558. setZoom(zoom + ZOOM_STEP)
  559. })
  560. document.getElementById('btn-zoom-reset').addEventListener('click', function () {
  561. resetView(true)
  562. })
  563. stage.addEventListener(
  564. 'wheel',
  565. function (e) {
  566. if (!mask.classList.contains('show')) return
  567. e.preventDefault()
  568. const delta = e.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP
  569. setZoom(zoom + delta, true)
  570. },
  571. { passive: false }
  572. )
  573. stage.addEventListener('pointerdown', function (e) {
  574. if (e.button !== 0) return
  575. dragging = true
  576. dragStartX = e.clientX
  577. dragStartY = e.clientY
  578. dragOriginX = offsetX
  579. dragOriginY = offsetY
  580. stage.classList.add('is-dragging')
  581. stage.setPointerCapture(e.pointerId)
  582. })
  583. stage.addEventListener('pointermove', function (e) {
  584. if (!dragging) return
  585. offsetX = dragOriginX + (e.clientX - dragStartX)
  586. offsetY = dragOriginY + (e.clientY - dragStartY)
  587. applyTransform()
  588. })
  589. function endDrag(e) {
  590. if (!dragging) return
  591. dragging = false
  592. stage.classList.remove('is-dragging')
  593. try {
  594. stage.releasePointerCapture(e.pointerId)
  595. } catch (_) {}
  596. }
  597. stage.addEventListener('pointerup', endDrag)
  598. stage.addEventListener('pointercancel', endDrag)
  599. mask.addEventListener('click', function (e) {
  600. if (e.target === mask) closePreview()
  601. })
  602. document.addEventListener('keydown', function (e) {
  603. if (!mask.classList.contains('show')) return
  604. if (e.key === 'Escape') closePreview()
  605. if (e.key === 'ArrowLeft') { angle -= 90; applyTransform() }
  606. if (e.key === 'ArrowRight') { angle += 90; applyTransform() }
  607. if (e.key === '+' || e.key === '=') setZoom(zoom + ZOOM_STEP)
  608. if (e.key === '-' || e.key === '_') setZoom(zoom - ZOOM_STEP)
  609. if (e.key === '0') resetView(true)
  610. })
  611. window.addEventListener('resize', function () {
  612. if (mask.classList.contains('show')) applyTransform()
  613. })
  614. </script>
  615. </body>
  616. </html>