Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 525fea7

Browse files
committed
feature: next/pre preview image
1 parent fe0ef63 commit 525fea7

3 files changed

Lines changed: 77 additions & 65 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"react-infinite-scroll-component": "^6.1.0",
7979
"react-konva": "17.0.2-6",
8080
"react-markdown": "^8.0.3",
81-
"react-multi-carousel": "^2.8.2",
8281
"react-redux": "^7.2.4",
8382
"react-router-dom": "^5.2.0",
8483
"react-scripts": "4.0.3",

src/routes/AnnotationPage/ImagePreview/index.tsx

Lines changed: 77 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import { Box, Skeleton, Typography } from "@mui/material";
1+
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
2+
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
3+
import {
4+
Box,
5+
Button,
6+
List,
7+
ListItem,
8+
Skeleton,
9+
Typography,
10+
} from "@mui/material";
211
import { BeforeUnload } from "components";
3-
import { useEffect, useMemo, useState } from "react";
4-
import Carousel from "react-multi-carousel";
12+
import { useEffect, useMemo, useRef, useState } from "react";
513
import "react-multi-carousel/lib/styles.css";
614
import { useDispatch, useSelector } from "react-redux";
715
import { resetCurrentStateDrawObject } from "reduxes/annotation/action";
@@ -129,13 +137,15 @@ function ImagePreview() {
129137
setIsOpenDiaglog(false);
130138
};
131139

132-
const responsive = {
133-
desktop: {
134-
breakpoint: { max: 3000, min: 1024 },
135-
items: 3,
136-
paritialVisibilityGutter: 60,
137-
slidesToSlide: 2,
138-
},
140+
const refList = useRef<HTMLUListElement>(null);
141+
// refList.current?.scroll
142+
const scrollLeft = () => {
143+
refList.current?.scroll({ left: refList.current.scrollLeft - 500 });
144+
};
145+
const scrollRight = () => {
146+
if (refList.current) {
147+
refList.current.scroll({ left: refList.current.scrollLeft + 500 });
148+
}
139149
};
140150
const renderContent = () => {
141151
if (!currentAnnotationFiles) {
@@ -147,60 +157,70 @@ function ImagePreview() {
147157
isActive={!!needConfirmChangePreviewImageDialog}
148158
message={QUIT_ANNOTATION_EDITOR_PROMPT_MESSAGE}
149159
/>
150-
<Box
151-
sx={{
152-
width: "95vw",
153-
lineHeight: "10vh",
154-
}}
155-
>
156-
<Carousel
157-
partialVisbile
158-
itemClass="image-item"
159-
responsive={responsive}
160-
deviceType="desktop"
161-
swipeable={false}
162-
draggable
163-
// showDots
160+
<Box display="flex">
161+
<Button
162+
color="primary"
163+
startIcon={<ArrowBackIosIcon />}
164+
onClick={scrollLeft}
165+
/>
166+
<List
167+
sx={{
168+
overflow: "auto",
169+
display: "flex",
170+
flexDirection: "row",
171+
padding: 0,
172+
width: "92vw",
173+
lineHeight: "8vh",
174+
}}
175+
ref={refList}
176+
id="scrollTest"
164177
>
165178
{currentAnnotationFiles.items.map((item) => (
166-
<ImagePreviewBadge key={item.filename} filename={item.filename}>
167-
<Box
168-
sx={{
169-
// background: `url(${fileThumbByImageName[imageName]})no-repeat center`,
170-
border:
171-
item.filename === currentPreviewImageName
172-
? "3px solid red"
173-
: "1px solid",
174-
backgroundSize: "contain",
175-
height: 60,
176-
cursor: "pointer",
177-
}}
178-
width="250px"
179-
position="relative"
180-
onClick={() => {
181-
handleSelectPreview(item.filename);
182-
}}
183-
>
179+
<ListItem key={item.filename}>
180+
<ImagePreviewBadge filename={item.filename}>
184181
<Box
185-
display="flex"
186-
justifyContent="center"
187-
height="100%"
188-
alignItems="center"
182+
sx={{
183+
// background: `url(${fileThumbByImageName[imageName]})no-repeat center`,
184+
border:
185+
item.filename === currentPreviewImageName
186+
? "3px solid red"
187+
: "1px solid",
188+
backgroundSize: "contain",
189+
height: 60,
190+
cursor: "pointer",
191+
}}
192+
width="250px"
193+
position="relative"
194+
onClick={() => {
195+
handleSelectPreview(item.filename);
196+
}}
189197
>
190-
<Typography
191-
sx={{
192-
color: "text.primary",
193-
p: 1,
194-
}}
195-
noWrap
198+
<Box
199+
display="flex"
200+
justifyContent="center"
201+
height="100%"
202+
alignItems="center"
196203
>
197-
{item.filename}
198-
</Typography>
204+
<Typography
205+
sx={{
206+
color: "text.primary",
207+
p: 1,
208+
}}
209+
noWrap
210+
>
211+
{item.filename}
212+
</Typography>
213+
</Box>
199214
</Box>
200-
</Box>
201-
</ImagePreviewBadge>
215+
</ImagePreviewBadge>
216+
</ListItem>
202217
))}
203-
</Carousel>
218+
</List>
219+
<Button
220+
color="primary"
221+
startIcon={<ArrowForwardIosIcon />}
222+
onClick={scrollRight}
223+
/>
204224
</Box>
205225
{currentPreviewImageName && nextPreviewImageName && (
206226
<ChangePreviewConfirmDialog

src/styles/custom.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,3 @@ input:-webkit-autofill:active {
112112
border: 2px solid !important;
113113
border-radius: 4px !important;
114114
}
115-
#__next {
116-
padding: 20px;
117-
}
118-
.image-item {
119-
padding: 20px 0 20px 20px;
120-
width: 300px !important;
121-
}

0 commit comments

Comments
 (0)