Spaces:
Sleeping
Sleeping
Upload 105 files
Browse files- src/components/MangaCard.tsx +17 -5
src/components/MangaCard.tsx
CHANGED
|
@@ -35,10 +35,18 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 35 |
const thumbnailUrl = thumbnail ? getThumbnailUrl(thumbnail) : undefined;
|
| 36 |
const [swiperInstance, setSwiperInstance] = useState<any>(null);
|
| 37 |
const [isZoomedIn, setIsZoomedIn] = useState(true);
|
|
|
|
| 38 |
|
| 39 |
useEffect(() => {
|
| 40 |
let interval: NodeJS.Timeout;
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
// Crossfade fallback for exactly 2 images
|
| 43 |
if (manga?.is_folder && folderThumbnails && folderThumbnails.length === 2) {
|
| 44 |
interval = setInterval(() => {
|
|
@@ -52,7 +60,7 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 52 |
setIsZoomedIn(false); // 1. Zoom out
|
| 53 |
|
| 54 |
setTimeout(() => {
|
| 55 |
-
swiperInstance.slideNext(600); // 2. Slide
|
| 56 |
|
| 57 |
setTimeout(() => {
|
| 58 |
setIsZoomedIn(true); // 3. Zoom in
|
|
@@ -62,7 +70,7 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 62 |
}
|
| 63 |
|
| 64 |
return () => clearInterval(interval);
|
| 65 |
-
}, [manga?.is_folder, folderThumbnails, swiperInstance]);
|
| 66 |
|
| 67 |
const handleDeleteClick = (e: React.MouseEvent) => {
|
| 68 |
e.stopPropagation();
|
|
@@ -86,7 +94,11 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 86 |
<div className="group cursor-pointer flex flex-col w-full max-w-xs">
|
| 87 |
<div
|
| 88 |
onMouseDown={onMouseDown}
|
| 89 |
-
onMouseEnter={
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
onDragStart={(e) => {
|
| 91 |
if (isCategoryPlusEnabled) e.preventDefault();
|
| 92 |
}}
|
|
@@ -160,7 +172,7 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 160 |
aspectRatio="2/3"
|
| 161 |
objectFit="cover"
|
| 162 |
className="w-full h-full"
|
| 163 |
-
imgClassName="
|
| 164 |
/>
|
| 165 |
</div>
|
| 166 |
))
|
|
@@ -171,7 +183,7 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 171 |
aspectRatio="2/3"
|
| 172 |
objectFit="cover"
|
| 173 |
className="w-full h-full"
|
| 174 |
-
imgClassName="transition-transform duration-700 group-hover:scale-110
|
| 175 |
/>
|
| 176 |
)}
|
| 177 |
</div>
|
|
|
|
| 35 |
const thumbnailUrl = thumbnail ? getThumbnailUrl(thumbnail) : undefined;
|
| 36 |
const [swiperInstance, setSwiperInstance] = useState<any>(null);
|
| 37 |
const [isZoomedIn, setIsZoomedIn] = useState(true);
|
| 38 |
+
const [isHovered, setIsHovered] = useState(false);
|
| 39 |
|
| 40 |
useEffect(() => {
|
| 41 |
let interval: NodeJS.Timeout;
|
| 42 |
|
| 43 |
+
if (!isHovered) {
|
| 44 |
+
if (manga?.is_folder && folderThumbnails && folderThumbnails.length > 2) {
|
| 45 |
+
setIsZoomedIn(true);
|
| 46 |
+
}
|
| 47 |
+
return;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
// Crossfade fallback for exactly 2 images
|
| 51 |
if (manga?.is_folder && folderThumbnails && folderThumbnails.length === 2) {
|
| 52 |
interval = setInterval(() => {
|
|
|
|
| 60 |
setIsZoomedIn(false); // 1. Zoom out
|
| 61 |
|
| 62 |
setTimeout(() => {
|
| 63 |
+
swiperInstance?.slideNext(600); // 2. Slide
|
| 64 |
|
| 65 |
setTimeout(() => {
|
| 66 |
setIsZoomedIn(true); // 3. Zoom in
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
return () => clearInterval(interval);
|
| 73 |
+
}, [manga?.is_folder, folderThumbnails, swiperInstance, isHovered]);
|
| 74 |
|
| 75 |
const handleDeleteClick = (e: React.MouseEvent) => {
|
| 76 |
e.stopPropagation();
|
|
|
|
| 94 |
<div className="group cursor-pointer flex flex-col w-full max-w-xs">
|
| 95 |
<div
|
| 96 |
onMouseDown={onMouseDown}
|
| 97 |
+
onMouseEnter={(e) => {
|
| 98 |
+
setIsHovered(true);
|
| 99 |
+
onMouseEnter?.(e);
|
| 100 |
+
}}
|
| 101 |
+
onMouseLeave={() => setIsHovered(false)}
|
| 102 |
onDragStart={(e) => {
|
| 103 |
if (isCategoryPlusEnabled) e.preventDefault();
|
| 104 |
}}
|
|
|
|
| 172 |
aspectRatio="2/3"
|
| 173 |
objectFit="cover"
|
| 174 |
className="w-full h-full"
|
| 175 |
+
imgClassName=""
|
| 176 |
/>
|
| 177 |
</div>
|
| 178 |
))
|
|
|
|
| 183 |
aspectRatio="2/3"
|
| 184 |
objectFit="cover"
|
| 185 |
className="w-full h-full"
|
| 186 |
+
imgClassName="transition-transform duration-700 group-hover:scale-110"
|
| 187 |
/>
|
| 188 |
)}
|
| 189 |
</div>
|