fix(media): enhance click handling and cursor styles in social media media components

- Updated the `PreviewMediaContent` and `SocialMediaGallery` components to improve click handling by stopping event propagation.
- Added cursor styles to indicate zoom functionality for better user experience.

These changes enhance the interactivity and visual feedback of media elements in the application.
This commit is contained in:
DIYgod
2025-09-05 20:43:21 +08:00
parent df5acca9b7
commit 335a38262a
2 changed files with 9 additions and 11 deletions
@@ -569,12 +569,8 @@ const DOMImageViewer: FC<{
smooth={true}
onInit={(e) => {
if (e.instance.wrapperComponent) {
e.instance.wrapperComponent.onclick = (e) => {
if (e.target instanceof HTMLDivElement && e.target.dataset.imageContainer) {
e.stopPropagation()
} else {
dismiss()
}
e.instance.wrapperComponent.onclick = () => {
dismiss()
}
}
}}
@@ -593,7 +589,7 @@ const DOMImageViewer: FC<{
wrapperProps={{
onClick: stopPropagation,
}}
wrapperClass="!w-full !h-full !absolute !inset-0"
wrapperClass="!w-full !h-full !absolute !inset-0 cursor-zoom-out"
contentClass="!w-full !h-full flex items-center justify-center"
>
<div
@@ -284,10 +284,11 @@ export const SocialMediaGallery = ({ entryId }: { entryId: string }) => {
type={media.type}
previewImageUrl={media.preview_image_url}
blurhash={media.blurhash}
className="data-[state=loading]:!bg-material-ultra-thick size-28 shrink-0"
className="data-[state=loading]:!bg-material-ultra-thick size-28 shrink-0 cursor-zoom-in"
loading="lazy"
proxy={proxySize}
onClick={() => {
onClick={(e) => {
e.stopPropagation()
previewMedia(
mediaList.map((m) => ({
url: m.url,
@@ -334,10 +335,11 @@ export const SocialMediaGallery = ({ entryId }: { entryId: string }) => {
type={m.type}
previewImageUrl={m.preview_image_url}
blurhash={m.blurhash}
className="aspect-square w-full rounded object-cover"
className="aspect-square w-full cursor-zoom-in rounded object-cover"
loading="lazy"
proxy={proxySize}
onClick={() => {
onClick={(e) => {
e.stopPropagation()
previewMedia(
media.map((m) => ({
url: m.url,