javascript - Slick Slider width recalculation -
i'm trying add slide in panel on slick container css. carousel works except new width not being calculated when space has been added. recalibrate once advance next slide i'd happen each time panel opened or closed. i've tried adding both margin , padding, neither makes difference. ideas?
https://jsfiddle.net/mhigley/dpf7mlpl/
html:
<button type="button" id="button"><i class="fa fa-arrow-right"></i></button> <aside> <h2>slide in panel</h2> <ol> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> </ol> </aside> <main role="main"> <div class="sections"> <section> <article> <h2>first slide</h2> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. labore libero nesciunt sequi doloribus, non reprehenderit laboriosam laudantium nemo reiciendis illum. libero eveniet quibusdam blanditiis aspernatur.</p> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. perspiciatis nihil quaerat, officiis autem, sunt dicta!</p> <figure> <img src="//unsplash.it/600/200?image=400" style="max-width: 100%;" alt=""> <figcaption>source: <a href="#">unsplash</a> , continuation of same source wrap multiple lines... not appear wrapping.</figcaption> </figure> <ul> <li>list item</li> <li>list item <ul> <li>nested list item</li> <li>nested list item</li> <li>nested list item <ul> <li>nested list item</li> <li>nested list item</li> <li>nested list item</li> </ul> </li> <li>nested list item</li> <li>nested list item</li> </ul> </li> <li>list item</li> <li>list item</li> <li>list item</li> </ul> <ol> <li>list item</li> <li>list item <ol> <li>nested list item</li> <li>nested list item</li> <li>nested list item <ol> <li>nested list item</li> <li>nested list item</li> <li>nested list item</li> <li>nested list item</li> </ol> </li> <li>nested list item</li> <li>nested list item</li> </ol> </li> <li>list item</li> <li>list item</li> <li>list item</li> </ol> <hr> <h3>subheadline</h3> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. adipisci, voluptatem. id alias, magnam molestias voluptas eveniet eos laboriosam quae nemo possimus ipsum esse, fuga nulla.</p> </article> </section> <section> <article> <h2>topic one</h2> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. labore libero nesciunt sequi doloribus, non reprehenderit laboriosam laudantium nemo reiciendis illum. libero eveniet quibusdam blanditiis aspernatur.</p> <figure> <img src="//unsplash.it/600/200?image=410" style="max-width: 100%;" alt=""> <figcaption>source: <a href="#">unsplash</a> , continuation of same source wrap multiple lines... not appear wrapping.</figcaption> </figure> <hr> <h3>subheadline</h3> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. eveniet facilis, atque aperiam, cum animi incidunt ad error voluptate voluptas nihil eius dolores accusamus vel provident.</p> </article> </section> <section> <article> <h2>topic two</h2> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. labore libero nesciunt sequi doloribus, non reprehenderit laboriosam laudantium nemo reiciendis illum. libero eveniet quibusdam blanditiis aspernatur.</p> <figure> <img src="//unsplash.it/600/200?image=420" style="max-width: 100%;" alt=""> <figcaption>source: <a href="#">unsplash</a></figcaption> </figure> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. consequatur distinctio cum molestias, dolor autem voluptatum. voluptates maxime molestias ipsam, ducimus debitis cupiditate illo nam temporibus, modi in quibusdam enim optio iste perferendis numquam amet odit neque! velit nisi in id rem blanditiis officiis quas, odit voluptate, corrupti fuga, architecto facere.</p> </article> </section> <section> <article> <h2>topic three</h2> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. labore libero nesciunt sequi doloribus, non reprehenderit laboriosam laudantium nemo reiciendis illum. libero eveniet quibusdam blanditiis aspernatur.</p> <figure> <img src="//unsplash.it/600/200?image=430" style="max-width: 100%;" alt=""> <figcaption>source: <a href="#">unsplash</a></figcaption> </figure> <blockquote> <p>a blockquote lorem ipsum dolor sit amet, consectetur adipisicing elit. repudiandae incidunt officiis, esse enim, nemo nesciunt.</p> </blockquote> </article> </section> </div> </main>
jquery:
$('.sections').slick({ speed: 250, usecss: true, cssease: 'ease-in-out', slidestoshow: 1, initialslide: 0, dots: false, infinite: true, adaptiveheight: true, draggable: true, nextarrow: '<button><i class="fa fa-angle-right"></i></button>', prevarrow: '<button><i class="fa fa-angle-left"></i></button>' }); var $btn = $('#button'), $body = $('body'); $btn.on('click', function() { $body.toggleclass('padify'); });
this line methods portion of slick documentation
$('.sections').slick('setposition');
you track end of aside transition , reset slick container.
$('aside', $body).on('webkittransitionend otransitionend otransitionend mstransitionend transitionend', function(){ $('.sections').slick('setposition'); });
Comments
Post a Comment