Spaces:
Running
Running
Commit ·
0761dec
1
Parent(s): cdcdbbf
ux: optimize mobile search result tap responsiveness and drawer closing animation smoothness
Browse files
webapp/tipitaka-web/src/components/layout/NavDrawer.tsx
CHANGED
|
@@ -48,9 +48,17 @@ const NavDrawer: React.FC = () => {
|
|
| 48 |
}, [activeTab, currentVolume]);
|
| 49 |
|
| 50 |
const jumpToPage = (volumeNumber: number, pageNum: number) => {
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
};
|
| 55 |
|
| 56 |
// Debounced suggestion fetch
|
|
@@ -314,10 +322,17 @@ const NavDrawer: React.FC = () => {
|
|
| 314 |
{results.map((res, i) => {
|
| 315 |
const vol = volumes.find(v => v.id === res.volume_id);
|
| 316 |
return (
|
| 317 |
-
<
|
| 318 |
key={i}
|
|
|
|
|
|
|
| 319 |
onClick={() => vol && jumpToPage(vol.volume_number, res.page_number)}
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
>
|
| 322 |
<div className="text-[10px] font-bold text-[#c8860a] mb-1">
|
| 323 |
เล่ม {vol?.volume_number} • หน้า {res.page_number}
|
|
@@ -326,7 +341,7 @@ const NavDrawer: React.FC = () => {
|
|
| 326 |
className="text-xs text-[#aaa] line-clamp-3 leading-relaxed"
|
| 327 |
dangerouslySetInnerHTML={{ __html: res.snippet }}
|
| 328 |
/>
|
| 329 |
-
</
|
| 330 |
);
|
| 331 |
})}
|
| 332 |
</div>
|
|
|
|
| 48 |
}, [activeTab, currentVolume]);
|
| 49 |
|
| 50 |
const jumpToPage = (volumeNumber: number, pageNum: number) => {
|
| 51 |
+
if (window.innerWidth < 1024) {
|
| 52 |
+
setNavOpen(false);
|
| 53 |
+
// Delay state updates to let the drawer slide-out animation run smoothly on mobile
|
| 54 |
+
setTimeout(() => {
|
| 55 |
+
setVolume(volumeNumber);
|
| 56 |
+
setPage(pageNum);
|
| 57 |
+
}, 250);
|
| 58 |
+
} else {
|
| 59 |
+
setVolume(volumeNumber);
|
| 60 |
+
setPage(pageNum);
|
| 61 |
+
}
|
| 62 |
};
|
| 63 |
|
| 64 |
// Debounced suggestion fetch
|
|
|
|
| 322 |
{results.map((res, i) => {
|
| 323 |
const vol = volumes.find(v => v.id === res.volume_id);
|
| 324 |
return (
|
| 325 |
+
<div
|
| 326 |
key={i}
|
| 327 |
+
role="button"
|
| 328 |
+
tabIndex={0}
|
| 329 |
onClick={() => vol && jumpToPage(vol.volume_number, res.page_number)}
|
| 330 |
+
onKeyDown={(e) => {
|
| 331 |
+
if (e.key === 'Enter' || e.key === ' ') {
|
| 332 |
+
vol && jumpToPage(vol.volume_number, res.page_number);
|
| 333 |
+
}
|
| 334 |
+
}}
|
| 335 |
+
className={`w-full text-left p-3 rounded-xl border ${s.border} ${s.tab} hover:border-[#c8860a] hover:shadow-sm transition-all cursor-pointer touch-action-manipulation`}
|
| 336 |
>
|
| 337 |
<div className="text-[10px] font-bold text-[#c8860a] mb-1">
|
| 338 |
เล่ม {vol?.volume_number} • หน้า {res.page_number}
|
|
|
|
| 341 |
className="text-xs text-[#aaa] line-clamp-3 leading-relaxed"
|
| 342 |
dangerouslySetInnerHTML={{ __html: res.snippet }}
|
| 343 |
/>
|
| 344 |
+
</div>
|
| 345 |
);
|
| 346 |
})}
|
| 347 |
</div>
|