react-swipeable-views icon indicating copy to clipboard operation
react-swipeable-views copied to clipboard

Question: Is it possible for the height of the swipeable view to limit to the current tab's data?

Open kdeasymoneysniper opened this issue 4 years ago • 5 comments

Hi, I just started using react-swipeable-views, and I am wondering if it is possible for the height of each view to be the height of the content for that specific tab/view? Right now, the height of all the views/tabs is the height of the longest content, and I am wondering if there are any solutions to solve this. Thanks!

kdeasymoneysniper avatar Jun 30 '20 10:06 kdeasymoneysniper

Im experiencing the same issue

bernardomichel avatar Aug 31 '20 22:08 bernardomichel

same issue here

KarenQiao avatar Sep 27 '20 06:09 KarenQiao

I think u can use the animateHeight prop to use the height of each view separately.

Screenshot 2021-02-02 at 15 55 11

denotter avatar Feb 02 '21 14:02 denotter

That works for me! Adding animateHeight adjusts the height for each tab. For dynamic heights I set the animateheight as false in state then set it as true when the api call had completed

lukeecart avatar Jun 19 '21 16:06 lukeecart

This example works without animateHeight, I think the trick is to set an additional hidden prop:

const steps = [ Step1, Step2, Step3, Step4 ]

return (
  <SwipeableViews index={activeStep} disabled={true}>
      {steps.map((step, index) => {
        const Step = step
        return (
          <div key={index} hidden={index !== activeStep} aria-labelledby={`step-${index}`}>
            <Step />
          </div>
        )
      })}
  </SwipeableViews>
)

schwamic avatar Sep 04 '21 07:09 schwamic