Skip to content

Commit

Permalink
revert: akiran#2329 to fix duplicated items
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Apr 1, 2024
1 parent 117e432 commit 94a8037
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
5 changes: 1 addition & 4 deletions src/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ export default class Slider extends React.Component {
if (settings === "unslick") {
const className = "regular slider " + (this.props.className || "");
return <div className={className}>{children}</div>;
} else if (
newChildren.length <= settings.slidesToShow &&
!settings.infinite
) {
} else if (newChildren.length <= settings.slidesToShow) {
settings.unslick = true;
}
return (
Expand Down
47 changes: 26 additions & 21 deletions src/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ const renderSlides = (spec) => {
// if slide needs to be precloned or postcloned
if (spec.infinite && spec.fade === false && !spec.unslick) {
let preCloneNo = childrenCount - index;
if (preCloneNo <= getPreClones(spec)) {
if (
preCloneNo <= getPreClones(spec) &&
childrenCount !== spec.slidesToShow
) {
key = -preCloneNo;
if (key >= startIndex) {
child = elem;
Expand All @@ -162,27 +165,29 @@ const renderSlides = (spec) => {
);
}

key = childrenCount + index;
if (key < endIndex) {
child = elem;
}
slideClasses = getSlideClasses({ ...spec, index: key });
postCloneSlides.push(
React.cloneElement(child, {
key: "postcloned" + getKey(child, key),
"data-index": key,
tabIndex: "-1",
className: classnames(slideClasses, slideClass),
"aria-hidden": !slideClasses["slick-active"],
style: { ...(child.props.style || {}), ...childStyle },
onClick: (e) => {
child.props && child.props.onClick && child.props.onClick(e);
if (spec.focusOnSelect) {
spec.focusOnSelect(childOnClickOptions);
if (childrenCount !== spec.slidesToShow) {
key = childrenCount + index;
if (key < endIndex) {
child = elem;
}
slideClasses = getSlideClasses({ ...spec, index: key });
postCloneSlides.push(
React.cloneElement(child, {
key: "postcloned" + getKey(child, key),
"data-index": key,
tabIndex: "-1",
className: classnames(slideClasses, slideClass),
"aria-hidden": !slideClasses["slick-active"],
style: { ...(child.props.style || {}), ...childStyle },
onClick: (e) => {
child.props && child.props.onClick && child.props.onClick(e);
if (spec.focusOnSelect) {
spec.focusOnSelect(childOnClickOptions);
}
}
}
})
);
})
);
}
}
});

Expand Down

0 comments on commit 94a8037

Please sign in to comment.