fix: demo card hover flash on safari

This commit is contained in:
shinya
2025-07-03 00:56:30 +08:00
parent 37aa342d5b
commit 038f94fa9b

View File

@@ -1,7 +1,7 @@
import { Link as LinkIcon, Search } from 'lucide-react'; import { Link as LinkIcon, Search } from 'lucide-react';
import Image from 'next/image'; import Image from 'next/image';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import React, { useState } from 'react'; import React from 'react';
interface DemoCardProps { interface DemoCardProps {
id: string; id: string;
@@ -45,7 +45,6 @@ function SearchCircle({
} }
const DemoCard = ({ id, title, poster, rate, type }: DemoCardProps) => { const DemoCard = ({ id, title, poster, rate, type }: DemoCardProps) => {
const [hover, setHover] = useState(false);
const router = useRouter(); const router = useRouter();
const handleClick = () => { const handleClick = () => {
@@ -58,7 +57,7 @@ const DemoCard = ({ id, title, poster, rate, type }: DemoCardProps) => {
onClick={handleClick} onClick={handleClick}
> >
{/* 海报图片区域 */} {/* 海报图片区域 */}
<div className='relative aspect-[2/3] w-full overflow-hidden rounded-md group-hover:scale-[1.02] transition-all duration-400 cubic-bezier(0.4, 0, 0.2, 1)'> <div className='relative aspect-[2/3] w-full overflow-hidden rounded-md transition-all duration-400 cubic-bezier(0.4, 0, 0.2, 1)'>
<Image <Image
src={poster} src={poster}
alt={title} alt={title}
@@ -78,15 +77,12 @@ const DemoCard = ({ id, title, poster, rate, type }: DemoCardProps) => {
)} )}
{/* 悬浮层 - 搜索按钮 */} {/* 悬浮层 - 搜索按钮 */}
<div className='absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-300 cubic-bezier(0.4, 0, 0.2, 1) flex items-center justify-center'> <div
<div style={{ willChange: 'opacity' }}
onMouseEnter={() => setHover(true)} className='absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-300 cubic-bezier(0.4, 0, 0.2, 1) flex items-center justify-center'
onMouseLeave={() => setHover(false)} >
className={`transition-all duration-300 cubic-bezier(0.4, 0, 0.2, 1) ${ <div className='transition-all duration-300 cubic-bezier(0.4, 0, 0.2, 1) scale-90 group-hover:scale-110 group-hover:rotate-12'>
hover ? 'scale-110 rotate-12' : 'scale-90' <SearchCircle className='group-hover:fill-green-500' />
}`}
>
<SearchCircle fillColor={hover ? '#22c55e' : 'none'} />
</div> </div>
</div> </div>