Skip to content

Changing parseInt of lineHeight to parseFloat to avoid rounding errors#32

Open
drukepple wants to merge 1 commit into
jeffchan:masterfrom
drukepple:issue-31
Open

Changing parseInt of lineHeight to parseFloat to avoid rounding errors#32
drukepple wants to merge 1 commit into
jeffchan:masterfrom
drukepple:issue-31

Conversation

@drukepple

Copy link
Copy Markdown

No description provided.

@Tuizi Tuizi added this to the 1.1.3 milestone Sep 22, 2016
@Tuizi Tuizi self-assigned this Sep 22, 2016
@Tuizi Tuizi added the bug label Sep 22, 2016
@Tuizi

Tuizi commented Oct 14, 2016

Copy link
Copy Markdown
Collaborator

Please add unit tests to cover your use case and to be sure nothing else is broken

@rogeriotaques

rogeriotaques commented Oct 19, 2016

Copy link
Copy Markdown

I'd like to suggest you another approach to fix that:

    if (this.options.lineHeight === 'auto') {

      ...

      if (lineHeightCss !== "normal") {
        lineHeight = Math.round(parseFloat(lineHeightCss));
      }

      this.options.lineHeight = lineHeight;
    }

    if (this.options.maxHeight === undefined) {
      this.options.maxHeight = Math.round(parseFloat(this.options.lines)) * Math.round(parseFloat(this.options.lineHeight));
    }

    ...

What do you think?
It has worked nicely for me!

@Tuizi

Tuizi commented Oct 19, 2016

Copy link
Copy Markdown
Collaborator

Yes it's correct. But I'm not sure someone will one day say: I want 1.6 lines :) (this.options.lines).

So I think the best think to do is:
this.options.maxHeight = Math.round(parseFloat(this.options.lines)) * parseFloat(this.options.lineHeight));

@rogeriotaques Can you create a PR with a fix and with test? @drukepple did not answer. Or if you are patient I will do it myself. This fix will be in the version 1.2 anyway

@rogeriotaques

rogeriotaques commented Dec 15, 2016 via email

Copy link
Copy Markdown

@rogeriotaques

Copy link
Copy Markdown

Hey, @Tuizi!

Oh my Gosh! It has been quite a (very) long time since you proposed that solution and I totally forgot to give you a PR, really sorry. 🙇‍♂️

I checked the release page and I don't think the version 1.2 was rolled out, am I right?

Is this project still active?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants