Skip to content

ion-slides (Swiper) autoHeight option doesn't adjust the container height to active slide #15079

Closed

Description

@tru03

Ionic version: (check one with "x")
(For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[ ] 3.x
[x] 4.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request

Current behavior:

If you use the ion-slides component with autoHeight option set to true, it doesn't adjust the ion-slides height to the active slide's content height as it supposed to.

Expected behavior:

The container should adjust to the content height of the active slide: http://idangero.us/swiper/demos/390-autoheight.html

Related code:

<ion-slides [options]="{autoHeight: true}">
    <ion-slide>
        <div style="width: 100%; height: 300px; background: red;"></div>
    </ion-slide>
    <ion-slide>
        <div style="width: 100%; height: 300px; background: blue;"></div>
    </ion-slide>
    <ion-slide>3</ion-slide>
</ion-slides>

Other information:

The ion-slide element (and .swiper-slide class) having a height of auto instead of 100% seems to fix the issue.

.swiper-container-autoheight, .swiper-container-autoheight .swiper-slide {
    height: auto;
}

This style definition which should provide the desired effect is not getting through the shadow DOM of this implementation.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

   ionic (Ionic CLI)          : 4.0.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.1
   @angular-devkit/core       : 0.7.0-rc.3
   @angular-devkit/schematics : 0.7.0-rc.3
   @angular/cli               : 6.0.8
   @ionic/ng-toolkit          : 1.0.0
   @ionic/schematics-angular  : 1.0.1

Activity

  1. ionitron-bot commented on Nov 29, 2018

    @ionitron-bot

    This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.

    If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know!

    Thank you for using Ionic!

  2. ionitron-bot commented on Nov 29, 2018

    @ionitron-bot

    Issue moved to: ionic-team/ionic-v3#661

  3. locked and limited conversation to collaborators on Nov 29, 2018
  4. unlocked this conversation on Dec 12, 2018
  5. added
    package: core
    type: bug
    and removed on Dec 13, 2018
  6. daem0ndev commented on Dec 15, 2018

    @daem0ndev
    Contributor

    The PR #16712 is ready to go and now exposes the Swiper instance's updateAutoHeight() method to allow for programmatically forcing the swiper container to update the height for the active slide when using the autoHeight = true option with your ion-slides.

  7. added a commit that references this issue on Jan 22, 2019
    835aea9
  8. ionitron-bot commented on Feb 21, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  9. locked and limited conversation to collaborators on Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: coretype: bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions