• Resolved celes15

    (@celes15)


    Hi guys,

    How I can call to slick slider?
    I want to change some settings but i can’t change it πŸ™
    I tried to call some element in Post Carousel – wp-block-getwid-post-carousel and others.
    I use method .slick('slickSetOption', 'vertical', true);

    but it didn’t work…

    • This topic was modified 4 years, 11 months ago by celes15.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support dimned

    (@dimned)

    Hi @celes15,
    Here is a code that will work on the front-end only

    window.addEventListener( 'load', function() {
        const baseClass = 'wp-block-getwid-post-carousel';
    
        const loadSlickContent = setInterval( () => {
            const sliderSelector = $( 'body' ).find( <code>.${ baseClass }</code> ).children();
            console.log( sliderSelector );
    
            if ( sliderSelector[ 0 ] ) {
                [sliderSelector].forEach( slider => {
                    slider.hasClass( 'slick-initialized' ) && slider.slick( 'unslick' );
    
                    slider.imagesLoaded().done( () => {
                        slider.not( '.slick-initialized' ).slick( {
                            arrows: true,
                        } );
                    } );
                } );
    
                clearInterval( loadSlickContent );
            }
        }, 100 );
    } );

    Let me know if it is helpful.

    Thread Starter celes15

    (@celes15)

    Great πŸ™‚

    I done small change

    baseclass deleted and swap sliderSelector

    const sliderSelector = $('.wp-block-getwid-post-carousel').children();

    Thanks

    • This reply was modified 4 years, 11 months ago by celes15.
    Plugin Support dimned

    (@dimned)

    You are welcome @celes15. It would be helpful if you review the plugin here https://wordpress.org/support/plugin/getwid/reviews/

    Thread Starter celes15

    (@celes15)

    Eh… it’s simetimes work but not always…
    I must force load like last script ?

    Plugin Support dimned

    (@dimned)

    Hi @celes15,
    You need to enqueue the script in this way

    function global_script_setup()
    {
        wp_enqueue_script( 'your-name', get_theme_file_uri( '/assets/js/file-name.js' ), array( 'jquery' ), wp_get_theme()->get( 'Version' ), true );
    }
    
    add_action( 'init', 'global_script_setup' );
    Thread Starter celes15

    (@celes15)

    hi @dimned

    Yeah I enqueued it earlier πŸ™‚
    With delay – jquery, slick and imagesloaded.

    Link to page

    Sometimes it working sometimes not πŸ™

    • This reply was modified 4 years, 10 months ago by celes15.
    Plugin Support dimned

    (@dimned)

    Hi @celes15,
    It looks like you have put 50 milliseconds instead of 100. Please, try to put back 100 milliseconds for correct slider initialization.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Call to Slick Slider – change settings’ is closed to new replies.