enzostvs HF staff commited on
Commit
7a5d25a
β€’
1 Parent(s): 74e73b3

add esc event to close drawer and viewer

Browse files
src/lib/components/community/viewer/Viewer.svelte CHANGED
@@ -55,6 +55,12 @@
55
  $page.url.searchParams.delete('gallery');
56
  goto(`/?${$page.url.searchParams.toString()}`);
57
  };
 
 
 
 
 
 
58
  </script>
59
 
60
  <div
@@ -144,4 +150,6 @@
144
  {/if}
145
  </div>
146
  {/if}
147
- </div>
 
 
 
55
  $page.url.searchParams.delete('gallery');
56
  goto(`/?${$page.url.searchParams.toString()}`);
57
  };
58
+
59
+ const handlePressEscape = (event: KeyboardEvent) => {
60
+ if (event.key === 'Escape') {
61
+ handleClose();
62
+ }
63
+ };
64
  </script>
65
 
66
  <div
 
150
  {/if}
151
  </div>
152
  {/if}
153
+ </div>
154
+
155
+ <svelte:window on:keydown|preventDefault={handlePressEscape} />
src/lib/components/models/drawer/Drawer.svelte CHANGED
@@ -37,6 +37,11 @@
37
  behavior: 'smooth'
38
  });
39
  }
 
 
 
 
 
40
  </script>
41
 
42
  <div
@@ -149,4 +154,5 @@
149
  </footer>
150
  </div>
151
  {/if}
152
- </div>
 
 
37
  behavior: 'smooth'
38
  });
39
  }
40
+ const handlePressEscape = (event: KeyboardEvent) => {
41
+ if (event.key === 'Escape') {
42
+ handleClose();
43
+ }
44
+ };
45
  </script>
46
 
47
  <div
 
154
  </footer>
155
  </div>
156
  {/if}
157
+ </div>
158
+ <svelte:window on:keydown|preventDefault={handlePressEscape} />