Git Product home page Git Product logo

Comments (8)

doitmax avatar doitmax commented on August 15, 2024

I am doing it like this:

        start: function(slider){ // init the height of the first item on start
            var $new_height = slider.slides.eq(0).height();     
            slider.height($new_height);                                     
        },          
        before: function(slider){ // init the height of the next item before slide
            var $new_height = slider.slides.eq(slider.animatingTo).height();                
            if($new_height != slider.height()){
                slider.animate({ height: $new_height  }, 250);
            }
        }

Works fine

from flexslider.

blustrps avatar blustrps commented on August 15, 2024

Thanks for getting back. That works ok but not well with media queries. When you scale the window, the height of the container doesn't resize appropriately.

That's ok though, i've moved on to just using the cycle plugin and fixed heights.

from flexslider.

doitmax avatar doitmax commented on August 15, 2024

Not a difficult task at all:

$(document).ready(function() {
    var $flexslider = jQuery('.flexslider').flexslider({
        start: function(slider){ // init the height of the first item on start
            var $new_height = slider.slides.eq(0).height();
                
            /* add a current class to the active item */
            slider.slides.removeClass('current');
            slider.slides.eq(0).addClass('current');
                
            slider.container.height($new_height);
                                                    
        },          
        before: function(slider){ // init the height of the next item before slide
            var $animatingTo = slider.slides.eq(slider.animatingTo);
            var $new_height = slider.slides.eq(slider.animatingTo).height();                
            
            /* add a current class to the active item */
            slider.slides.removeClass('current');
            $animatingTo.addClass('current');
            
            if($new_height != slider.container.height()){
                slider.container.stop().animate({ height: $new_height  }, 250);
            }
        }           
    });
});
$(window).resize(function() {   
    clearTimeout(this.id);
    this.id = setTimeout(doResizeSlide, 500);           
})
    
function doResizeSlide() {
    var slider = jQuery('.flexslider ul.slides');
    var newHeight = jQuery('li.current', slider).height();          
    slider.stop().animate({ height: newHeight });   
}

The timeout is set to avoid conflicts on resize with responsive columns layout like skeleton or similar.

Cheers

from flexslider.

tylernotfound avatar tylernotfound commented on August 15, 2024

smoothHeight property has been added to FlexSlider 2, baking in this functionality.

from flexslider.

himerus avatar himerus commented on August 15, 2024

Where is this functionality implemented? I don't see a 2.x branch available, or a commit to latest code that implements this "smoothHeight" property...

Needing this on a current use case, and would prefer to use a baked in functionality before implementing the suggestion(s) above.

from flexslider.

tylernotfound avatar tylernotfound commented on August 15, 2024

On my local machine... :)

FlexSlider 2 beta branch will go up soon. Very soon.

from flexslider.

pixelready avatar pixelready commented on August 15, 2024

I'm implementing the above solution by doitmax as a temporary fix while I wait for flexslider 2's native smoothHeight property (thanks in advance mbmufffin!).

It works perfectly on iOS devices for me (both iPhone and iPad) but not in Firefox, Chrome, or Safari on the desktop. On the desktop browsers, the slide height starts to animate like it's collapsing to the correct height, then pops back to the height of the largest slide. Any ideas?

from flexslider.

mr-crunchy avatar mr-crunchy commented on August 15, 2024

@doitmax Thank you!
Those lines did work well for me, I've just to make a few changes on timings (animation slider/height slider) to get it working.

from flexslider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.