mirror of
https://github.com/Afilmory/afilmory
synced 2026-02-01 22:48:17 +00:00
fix: exit animation target on ListView (#210)
This commit is contained in:
@@ -193,6 +193,7 @@ const PhotoCard = ({ photo }: { photo: PhotoManifest }) => {
|
||||
className="relative w-full shrink-0 cursor-pointer overflow-hidden lg:h-full lg:w-56"
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
data-photo-id={photo.id}
|
||||
style={
|
||||
// 移动端:根据宽高比计算高度
|
||||
{
|
||||
|
||||
@@ -69,7 +69,11 @@ export const usePhotoViewerTransitions = ({
|
||||
const resolveTriggerElement = useCallback((): HTMLElement | null => {
|
||||
if (!currentPhoto) return null
|
||||
|
||||
if (triggerElement && triggerElement.isConnected) {
|
||||
const isElementForCurrentPhoto = (el: HTMLElement) => {
|
||||
return el.dataset.photoId === currentPhoto.id
|
||||
}
|
||||
|
||||
if (triggerElement && triggerElement.isConnected && isElementForCurrentPhoto(triggerElement)) {
|
||||
cachedTriggerRef.current = triggerElement
|
||||
return triggerElement
|
||||
}
|
||||
@@ -82,7 +86,11 @@ export const usePhotoViewerTransitions = ({
|
||||
return liveTriggerEl
|
||||
}
|
||||
|
||||
if (cachedTriggerRef.current && cachedTriggerRef.current.isConnected) {
|
||||
if (
|
||||
cachedTriggerRef.current &&
|
||||
cachedTriggerRef.current.isConnected &&
|
||||
isElementForCurrentPhoto(cachedTriggerRef.current)
|
||||
) {
|
||||
return cachedTriggerRef.current
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user