Skip to content
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

Unslick not working as expected #2

Open
chinhphan099 opened this issue Oct 9, 2020 · 8 comments
Open

Unslick not working as expected #2

chinhphan099 opened this issue Oct 9, 2020 · 8 comments

Comments

@chinhphan099
Copy link

@ubergeoff

https://i.gyazo.com/1d024c67db83cc0f130e5abe2ccd0c3d.mp4

I ran unslick function and all slide item are removed :)

@ubergeoff
Copy link
Owner

ubergeoff commented Oct 9, 2020

Hi there @chinhphan099 - is this not the correct/expected result..?

If you "unslick" - then do you not wish to destroy/unload the current carousel..?

What is your expected behaviour..?

@chinhphan099
Copy link
Author

chinhphan099 commented Oct 9, 2020

I want after destroy slider. All HTML element have to back as before init slider. Because when the popup is shown again, I'd like to re-init the slider.
As you see in the video, all slide items are removed.

@chinhphan099 chinhphan099 changed the title Unslick not working Unslick not working as expected Oct 9, 2020
@ubergeoff
Copy link
Owner

I think you have 1 or two options.

  1. Just dont use "unslick" - if you want to keep the the pop-up as before.
    OR
  2. If you do "unslick" - then you must reinitialize the the Slick object..?

@chinhphan099
Copy link
Author

👍 I can hot fix now. But it better if after unslick, all element still not remove as begin, like Slick Slider (jquery version)

@chinhphan099
Copy link
Author

I reinitialize because when I init I have an option of initialSlide, I don't want to use "slickGoTo"

@ubergeoff
Copy link
Owner

@chinhphan099 - Please can you share an example again..?

@chinhphan099
Copy link
Author

Hey @ubergeoff ,

I updated some codes in my repository. In this commit: chinhphan099/chinhphan099.github.io@8f5a51c

  1. Optimized at line 578. Remove line 624
  2. Recover original Slide item after unslick.
  3. Move out focus and blur event. Avoid repeating focus and blur events when re-init slick slider. Then update the called function to:
    _.$slider.addEventListener('focus', _.focus);
    _.$slider.addEventListener('blur', _.blur);

demo: https://chinhphan099.github.io/slick-vanilla/index.html
console log run: commentSlick.unslick(); to destroy
Re-slick: var commentSlick = new Slick(document.querySelector('.comments--root .w_inner'), {infinite: false});

@facu-gamond
Copy link

@ubergeoff hey! amazing work with this
How can I use the slick events? I'm trying this:

slider.$slider.addEventListener('beforeChange', (event, slick, currentSlide, nextSlide) => {
            console.log(event, slick, currentSlide, nextSlide);
        });

but args slick, currentSlide, nextSlide are empty.
Same happens with the rest of the events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants