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

Centering issue #462

Open
AaronNGray opened this issue Mar 19, 2024 · 2 comments
Open

Centering issue #462

AaronNGray opened this issue Mar 19, 2024 · 2 comments

Comments

@AaronNGray
Copy link

AaronNGray commented Mar 19, 2024

Describe the bug
There is a problem with centering the react-zoom-pan-pinch image 'editor'.

To Reproduce
https://github.com/AaronNGray/react-zoom-pan-pinch-example

#root {
  position:relative;
  margin: 0 auto;
  min-height: 100%;
  width: 100%;
}
#wrapper {
  position:relative;
  width: 1470px;
  max-width: 1470px;
  min-height: 100%;
  border: 1px solid red;  
}
#header {
  position: relative;
  top: 0px;
  left: 0px;
  width: 1470px;
  height: 460px;
  overflow: hidden;
}
    <div id="wrapper">
      <div id="header">
        <TransformWrapper minScale={0.1} maxScale={16}>
          <TransformComponent wrapperStyle={{ maxHeight: "calc(100vh - 50px)" }}>
            <img src="Anthropocene.jpg" alt="test" />
          </TransformComponent>
        </TransformWrapper>
      </div>

generated code :-

<div id="wrapper">
  <div id="header">
    <div class="react-transform-wrapper transform-component-module_wrapper__SPB86 " style="width: 100%; max-height: calc(-50px + 100vh);">
      <div class="react-transform-component transform-component-module_content__FBWxo " style="transform: translate(0px, 0px) scale(1);">
        <img src="Anthropocene.jpg" alt="test">
      </div>
    </div>
  </div>
</div>

Given the following there is a width: fit-content; from transform-component-module_wrapper__SPB86

Expected behavior
Be able to center the #header in #wrapper.

Screenshots
header

Desktop (please complete the following information):

  • OS: Windows 11
  • Chrome
  • Version 122.0.6261.129 (Official Build) (64-bit)

Additional context
As I say I think the width: fit-content; from transform-component-module_wrapper__SPB86 is the issue that is stopping the header from being centered.

@01e9
Copy link

01e9 commented Apr 6, 2024

Had similar issue with width: fit-content;

  • styles.scss

    .wrapper {
        width: 100% !important;
    }
  • index.tsx

    import styles from './styles.scss';
    
    <TransformWrapper centerOnInit>
        <TransformComponent wrapperClass={styles.wrapper}>
            <img ...

@0xanonymeow
Copy link

try

<TransformComponent
    wrapperStyle={{
        width: '100dvw',

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