carousel.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import Carousel from 'react-material-ui-carousel'
  2. import { Box } from '@mui/system';
  3. import { url } from '../../App';
  4. // карусель
  5. export function MyCarouselPost({ postImages }) {
  6. // console.log('postImages: ', postImages)
  7. return (postImages &&
  8. <Carousel
  9. autoPlay={false}
  10. cycleNavigation={false}
  11. animation={"slide"}
  12. indicatorContainerProps={{
  13. style: {
  14. marginTop: '-50px',
  15. zIndex: 999,
  16. position: 'inherit'
  17. }
  18. }}
  19. className='myCarousel'
  20. sx={{
  21. // flexDirection: 'column',
  22. // flex: '1 1 auto',
  23. width: '100%',
  24. height: '100%',
  25. }}
  26. >
  27. {
  28. postImages.map(item =>
  29. // <Box
  30. // sx={{
  31. // paddingTop: '100%',
  32. // backgroundSize: 'contain',
  33. // backgroundColor: 'black',
  34. // backgroundImage: `url(/images/noPhoto.png)`,
  35. // backgroundRepeat: 'no-repeat',
  36. // backgroundPosition: 'center',
  37. // }}
  38. // key={item?.url}
  39. // style={item?.url &&
  40. // { backgroundImage: `url(${url + item.url})` }
  41. // }
  42. // />
  43. <Box sx={{
  44. width: '100%',
  45. height: '743px',
  46. overflow: 'hidden',
  47. position: 'relative'
  48. }}
  49. key={item?.url}
  50. >
  51. <img
  52. style={{
  53. position: 'absolute',
  54. top: '50%',
  55. left: '50%',
  56. transform: 'translate(-50%, -50%)',
  57. width: '100%',
  58. height: '100%',
  59. objectFit: 'contain',
  60. objectPosition: 'center'
  61. }}
  62. src={url + item.url}
  63. />
  64. </Box>
  65. )
  66. }
  67. </Carousel >
  68. )
  69. }