WinterCore / react-text-transition

Animate your text changes
MIT License
614 stars 26 forks source link

Placeholder width doesn't take `fontSize` into account #5

Closed inje closed 5 years ago

inje commented 5 years ago

User Story

I tried adding a fontSize to the style and className properties but they don't update the width of the transition text.

In the screenshot below, the large text overlaps other elements because the width is not updated from the given styles.

Screen Shot 2019-03-21 at 1 39 08 PM

Solution

Adding the same fontSize to the .placeholder span fixes the issue, since the transition text grabs its width from the placeholder text when the inline prop is true.

https://github.com/WinterCore/react-text-transition/blob/master/src/components/TextTransition.js#L50

Screen Shot 2019-03-21 at 1 47 32 PM

To Reproduce

With style

<TextTransition
  inline
  overflow
  style={{ fontSize: '86px', }}
  text="Foo Bar"
/>

With className

/**
 * styles.css
 */
.transition-text {
  font-size: 86px;
}

/**
 * index.jsx
 */
<TextTransition
  className="transition-text"
  inline
  overflow
  text="Foo Bar"
/>
WinterCore commented 5 years ago

Hi and sorry for being late Are you sure there's nothing else conflicting with the styles of any of the elements of this plugin ? I wasn't able to reproduce this issue. I might be doing something wrong. Could you try to reproduce it in a Codesandbox example and sending me the link. You could also fork the repo and use the demo to do that. Thanks in advance

inje commented 5 years ago

That's interesting. I'm not seeing it in CodeSandBox: https://codesandbox.io/s/jvj629pzw9

Might be something on my end. Let me dig in deeper to verify.

WinterCore commented 5 years ago

Closing this issue due to inactivity