Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override container height - how to add a custom height value for the container #59

Open
iarrieta90 opened this issue Oct 15, 2020 · 2 comments

Comments

@iarrieta90
Copy link

Hi, first of all I would like to thank you for this amazing image comparison slider, it is so powerful and easy to use!

I am having an issue when trying to set my desired height value for the container. I already tried adding the image css props, and also tried to style a div component but still doesn't work properly:

I had a look through the source code, and there seems to be a preset to make the height match an ideal width-height ratio that might be preventing further changes for the height value:

// calc and set the container's size
const idealContainerHeight = containerWidth * idealWidthHeightRatio;
setContainerHeight(idealContainerHeight);

When inspecting the code at the browser, there is a

generated by the component that overrides the styles I set for the parent div.

Is there any possible way to override this width-height ratio, or any other way to set any desired height for the container?

Thanks a lot!!

@wflemingnz-retired
Copy link

I had the same problem, for now I'm using https://github.com/OnurErtugral/react-image-comparison-slider

@LorepRocks
Copy link

LorepRocks commented May 2, 2022

Hi, if someone is still struggling with this issue, what I did was wrap the <ReactCompareImage> with a div and apply style to the attribute selector:

 resizableContainer: {
    '& [data-testid="container"]':{
      height: '640px !important'
    }
  }

   <div className={classes.resizableContainer}>
            <ReactCompareImage 
              leftImage={photoOne} 
              rightImage={photoTwo} 
            />
   </div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants