akiran / akiran/react-slick

CenterMode with Infinite and Variable Width not centering properly

オープン
#2,347 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
11.9k
フォーク
2.1k
PR マージ指標
30日以内にマージされた PR はありません

説明

The slider is sitting in a container that is 100% the width of the viewport and width is determined by each image element child which is ultimately governed by the height of the parent container. These are native images in an img tag so they proportionally scale their aspect ratio according to the height.

The centering is off from the center by a small amount that is variable on each item. I'm not sure what is wrong with the centering calculation, but it is wrong and producing off-center results. See several screenshots below.

Screenshot 2024-02-16 at 3 47 27 PM

Screenshot 2024-03-06 at 8 47 55 PM

Screenshot 2024-03-06 at 8 48 29 PM

![PixelSnap 2024-03-06 at 20 55 58@2x](https://github.com/akiran/react-slick/assets/202188/96f2e9b8-93d8-42bb-b6a8-c898c8299c00)

``

```javascript
const slide_settings = {
infinite: true,
slidesToScroll: 1,
slidesToShow: 1,
arrows: false,
dots: false,
speed: 400,
swipe: true,
swipeToSlide: true,
easing: "ease-out",
className: "projectslider",
variableWidth: true,
centerMode: true,
centerPadding: "0px",
afterChange: (index) => {
setCurrentMedia(index);
},
};
```

```css
.projectslider {
height: 100%;
padding: 0;

.slick-list {
height: 100%;

.slick-track {
height: 100%;

.slick-slide {
height: 100%;

> div {
height: 100%;
width: auto;

figure {
outline: none;
height: 100%;
width: auto !important;
margin: 0;
padding: 0 25px;
position: relative;
z-index: 1;

img,
video {
cursor: pointer;
height: 100%;
outline: none;
width: auto;
}
}
}
}
}
}
}
```

```javascript



{mediaData.map((media, index) =>
media.type === "videotype" ? (
goToSlide(index)} key={index}>




) : (
goToSlide(index)}>
{media.caption}

)
)}


```

You can see a live version [here](https://studio-jarvis-git-v2-studio-jarvis.vercel.app/).

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。