YuSaZh commited on
Commit
b8bba91
·
1 Parent(s): c94ae12

Fix image PWA touch and scrolling

Browse files
web/src/app/globals.css CHANGED
@@ -116,6 +116,11 @@
116
  * {
117
  @apply border-border outline-ring/50;
118
  }
 
 
 
 
 
119
  body {
120
  @apply bg-background text-foreground;
121
  }
 
116
  * {
117
  @apply border-border outline-ring/50;
118
  }
119
+ html,
120
+ body {
121
+ overscroll-behavior: none;
122
+ }
123
+
124
  body {
125
  @apply bg-background text-foreground;
126
  }
web/src/app/image/components/image-results.tsx CHANGED
@@ -213,18 +213,18 @@ export function ImageResults({
213
  }}
214
  />
215
  </button>
216
- <div className="hidden items-center justify-between gap-2 px-3 py-3 sm:flex">
217
- <div className="min-w-0 text-xs text-stone-500">
218
  <span>结果 {index + 1}</span>
219
- {imageMeta ? <span className="ml-2 text-stone-400">{imageMeta}</span> : null}
220
  </div>
221
  <Button
222
  variant="outline"
223
  size="sm"
224
- className="rounded-full border-stone-200 bg-white text-stone-700 hover:bg-stone-50"
225
  onClick={() => onContinueEdit(selectedConversation.id, image)}
226
  >
227
- <Sparkles className="size-4" />
228
  加入编辑
229
  </Button>
230
  </div>
 
213
  }}
214
  />
215
  </button>
216
+ <div className="flex flex-col gap-1 px-0.5 py-1 text-[10px] sm:flex-row sm:items-center sm:justify-between sm:gap-2 sm:px-3 sm:py-3 sm:text-xs">
217
+ <div className="min-w-0 text-stone-500">
218
  <span>结果 {index + 1}</span>
219
+ {imageMeta ? <span className="block text-stone-400 sm:ml-2 sm:inline">{imageMeta}</span> : null}
220
  </div>
221
  <Button
222
  variant="outline"
223
  size="sm"
224
+ className="h-7 w-fit rounded-full border-stone-200 bg-white px-2 text-[10px] text-stone-700 hover:bg-stone-50 sm:h-8 sm:px-3 sm:text-xs"
225
  onClick={() => onContinueEdit(selectedConversation.id, image)}
226
  >
227
+ <Sparkles className="size-3 sm:size-4" />
228
  加入编辑
229
  </Button>
230
  </div>
web/src/app/image/page.tsx CHANGED
@@ -1115,7 +1115,7 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
1115
 
1116
  return (
1117
  <>
1118
- <section className="mx-auto grid h-[calc(100dvh-6.25rem)] min-h-0 w-full max-w-[1380px] grid-cols-1 gap-2 px-0 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:h-[calc(100dvh-5rem)] sm:gap-3 sm:px-3 sm:pb-6 lg:grid-cols-[240px_minmax(0,1fr)]">
1119
  <div className="hidden h-full min-h-0 border-r border-stone-200/70 pr-3 lg:block">
1120
  <ImageSidebar
1121
  conversations={conversations}
@@ -1188,7 +1188,7 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
1188
 
1189
  <div
1190
  ref={resultsViewportRef}
1191
- className="hide-scrollbar min-h-0 flex-1 overflow-y-auto px-1 py-2 sm:px-4 sm:py-4"
1192
  >
1193
  <ImageResults
1194
  selectedConversation={selectedConversation}
 
1115
 
1116
  return (
1117
  <>
1118
+ <section className="mx-auto grid min-h-0 flex-1 w-full max-w-[1380px] grid-cols-1 gap-2 px-0 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:gap-3 sm:px-3 sm:pb-6 lg:grid-cols-[240px_minmax(0,1fr)]">
1119
  <div className="hidden h-full min-h-0 border-r border-stone-200/70 pr-3 lg:block">
1120
  <ImageSidebar
1121
  conversations={conversations}
 
1188
 
1189
  <div
1190
  ref={resultsViewportRef}
1191
+ className="hide-scrollbar min-h-0 flex-1 overscroll-contain overflow-y-auto px-1 py-2 sm:px-4 sm:py-4"
1192
  >
1193
  <ImageResults
1194
  selectedConversation={selectedConversation}
web/src/app/layout.tsx CHANGED
@@ -30,8 +30,8 @@ export default function RootLayout({
30
  }}
31
  >
32
  <Toaster position="top-center" richColors offset={48} />
33
- <main className="min-h-screen bg-[radial-gradient(circle_at_top_left,_rgba(255,255,255,0.92),_rgba(245,239,231,0.96)_42%,_rgba(240,235,227,0.99)_100%)] px-4 py-2 text-stone-900 sm:px-6 lg:px-8">
34
- <div className="mx-auto flex max-w-[1440px] flex-col gap-5">
35
  <TopNav />
36
  {children}
37
  </div>
 
30
  }}
31
  >
32
  <Toaster position="top-center" richColors offset={48} />
33
+ <main className="h-screen overflow-hidden bg-[radial-gradient(circle_at_top_left,_rgba(255,255,255,0.92),_rgba(245,239,231,0.96)_42%,_rgba(240,235,227,0.99)_100%)] px-4 pt-0 pb-2 text-stone-900 sm:px-6 sm:pt-2 lg:px-8">
34
+ <div className="mx-auto flex h-full max-w-[1440px] flex-col gap-2 sm:gap-5">
35
  <TopNav />
36
  {children}
37
  </div>
web/src/components/image-lightbox.tsx CHANGED
@@ -75,6 +75,12 @@ export function ImageLightbox({
75
  swipeStartRef.current = { x: touch.clientX, y: touch.clientY };
76
  }, []);
77
 
 
 
 
 
 
 
78
  const handleTouchEnd = useCallback(
79
  (event: React.TouchEvent<HTMLDivElement>) => {
80
  const start = swipeStartRef.current;
@@ -156,6 +162,7 @@ export function ImageLightbox({
156
  className="flex max-h-[90vh] max-w-[90vw] items-center justify-center"
157
  onClick={() => onOpenChange(false)}
158
  onTouchStart={handleTouchStart}
 
159
  onTouchEnd={handleTouchEnd}
160
  >
161
  <img
 
75
  swipeStartRef.current = { x: touch.clientX, y: touch.clientY };
76
  }, []);
77
 
78
+ const handleTouchMove = useCallback((event: React.TouchEvent<HTMLDivElement>) => {
79
+ if (event.touches.length !== 1) {
80
+ swipeStartRef.current = null;
81
+ }
82
+ }, []);
83
+
84
  const handleTouchEnd = useCallback(
85
  (event: React.TouchEvent<HTMLDivElement>) => {
86
  const start = swipeStartRef.current;
 
162
  className="flex max-h-[90vh] max-w-[90vw] items-center justify-center"
163
  onClick={() => onOpenChange(false)}
164
  onTouchStart={handleTouchStart}
165
+ onTouchMove={handleTouchMove}
166
  onTouchEnd={handleTouchEnd}
167
  >
168
  <img