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" ;
211import { 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" ;
513import "react-multi-carousel/lib/styles.css" ;
614import { useDispatch , useSelector } from "react-redux" ;
715import { 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
0 commit comments