-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"slick-current" is always on first slide despite initialSlide != 0 #1874
Comments
Thanks for reporting. I will fix it in a day or two |
@akiran |
@NikolaStanisavljevic |
@alexdroste |
This bug appears only when you set |
@morganHipay Yeah. That seems to be the problem. Thank you. |
any update? same issue here |
i faced same issue :/ anybody can help me? |
i too faced same issue |
@akiran , is there any solution for this? |
@akiran hello! any chance to fix it? This problem is still alive. |
Is it fixed on some version? I used 0.28.1 upgraded to latest 0.29, still get the problem. |
I hot-fixed my node_modules, and added the targetSlide line. I can't currently check this out and build the package, as I do not have node.js installed into my desktop(I run everything via containers, so that my desktop can stay clean). I was experiencing this problem with infinite=false, then using paging, and setting initialSlide=8 when slidesToScroll=4. Clicking previous would then jump to the very first page. |
I was experiencing same issue and I figured out that that it came due to version upgrade from On version But in newer version, Solution: |
@akiran Why at the latest release(0.30.0) you removed this fixed code? ref: e1e766f For who can't wait the patch you can do something like this.. // #region - hacky initialSlide
/**
* `initialSlide` config is currently bug on react-slide 0.30.0
* Will remove this and change to use the config util we got patch.
* Ref: https://github.com/akiran/react-slick/issues/1946#issuecomment-768935762
*/
const slideElementRef = useRef<Slider | null>(null);
const [hasSetInitialSlide, setHasSetInitialSlide] = useState(false);
useEffect(() => {
if (!hasSetInitialSlide && slideElementRef.current && typeof initialSlide === 'number') {
slideElementRef.current?.slickGoTo(initialSlide, true);
setHasSetInitialSlide(true);
}
}, [initialSlide, hasSetInitialSlide]);
// #endregion - hacky initialSlide |
@akegvd I will check it and revert the fix |
fixed #1874: slick-current is always on first slide despite initialSl…
v0.27.9
If I set initialSlide to something != 0, the internal index as well as the css class "slick-center" are set correctly.
However, the css class "slick-current" is on the wrong element. It is always on the first one.
In the example picture below the slider was rendered with initialSlide = 2.
The text was updated successfully, but these errors were encountered: