Slick: adaptiveHeight + container animation

Created on 20 May 2015  路  6Comments  路  Source: kenwheeler/slick

Hi everyone,

is there any chance to disable height animation when adaptiveHeight is set to true? I figured out that is not css animation but jquery animate() or something. Any ideas?

Considering Feature Request

Most helpful comment

+1

In the meantime, I think @michaltowilk suggests the following:

Slick.prototype.animateHeight = function() {
        var _ = this;
        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
            _.$list.height(targetHeight); //set height, instead of animate
        }
    };

On https://github.com/kenwheeler/slick/blob/master/slick/slick.js#L235

All 6 comments

I have adaptiveHeight set to true and it doesn't animate, I was hoping to figure out how. It just jumps up and down.

Maybe with speed set to "0"?
Anyway I solved my problem in slick core. AdaptiveHeight uses animate({ },speed) to change container height. I just replaced .animate() with .height()

Thats weird because setting to 0 does the same thing mine does already with a speed setting, no animation. It just flickers to the new height.

Adding as a feature

+1

In the meantime, I think @michaltowilk suggests the following:

Slick.prototype.animateHeight = function() {
        var _ = this;
        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
            _.$list.height(targetHeight); //set height, instead of animate
        }
    };

On https://github.com/kenwheeler/slick/blob/master/slick/slick.js#L235

Try this css if you want animation

.slick-list { transition: all 0.5s ease-in-out; }

as by default animation is not working

Was this page helpful?
0 / 5 - 0 ratings