svelte-fit icon indicating copy to clipboard operation
svelte-fit copied to clipboard

Simplifying logic in resize_text

Open http-teapot opened this issue 3 years ago • 2 comments

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

http-teapot avatar Sep 05 '22 20:09 http-teapot

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.

height[bot] avatar Sep 05 '22 20:09 height[bot]

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.

paoloricciuti avatar Oct 04 '22 07:10 paoloricciuti