react-compare-image icon indicating copy to clipboard operation
react-compare-image copied to clipboard

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

Open iarrieta90 opened this issue 4 years ago • 2 comments

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!!

iarrieta90 avatar Oct 15 '20 23:10 iarrieta90

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

wflemingnz-retired avatar Dec 29 '20 16:12 wflemingnz-retired

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>

LorepRocks avatar May 02 '22 22:05 LorepRocks