Skip to content

Simplifying logic in resize_text#1

Open
http-teapot wants to merge 2 commits intoleveluptuts:mainfrom
http-teapot:main
Open

Simplifying logic in resize_text#1
http-teapot wants to merge 2 commits intoleveluptuts:mainfrom
http-teapot:main

Conversation

@http-teapot
Copy link

There was a bit of redundancy in the code:

  • variables i and size are nearly identical
  • variable overflow isn't necessary: it starts at false, while executes at least once, it assigns function result to a value then check for falsiness – instead could check function result directly in while

I am unsure why size = i - 2 was needed; if i fits then why decrements by 2 pixels?

Great library, could def use it in our team

@height
Copy link

height bot commented Sep 5, 2022

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@paoloricciuti
Copy link

I think the -2 is needed to still prevent overflowing in some cases:

https://svelte.dev/repl/f510622fc2964815909e5f0ba553088e?version=3.50.0

Here's a link to a svelte repl: if you check or uncheck the checbox above you can swap between the two implementations and you can see commenting the line 31 make the action behave differently from the original package.

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

Successfully merging this pull request may close these issues.

2 participants