Skip to content

Fix rounding error when calculating element width - #17

Merged
ZouYouShun merged 1 commit into
ZouYouShun:masterfrom
anteq:master
Jan 11, 2019
Merged

Fix rounding error when calculating element width#17
ZouYouShun merged 1 commit into
ZouYouShun:masterfrom
anteq:master

Conversation

@anteq

@anteq anteq commented Jan 10, 2019

Copy link
Copy Markdown

When width of rootElm is not an integer, the decimal part is being lost in the width calculation. Rounding of width may cause to display the carousel improperly (showing 1px of next image).
According to the Mozilla developer docs https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth , proper solution to get exact width is usage of getBoundingClientRect().
Can be used safely in modern browsers: https://caniuse.com/#feat=getboundingclientrect

@anteq anteq changed the title Fix rounding error when using clientWidth Fix rounding error when calculating element width Jan 10, 2019
@ZouYouShun

Copy link
Copy Markdown
Owner

Thanks a lot, @anteq

@ZouYouShun
ZouYouShun merged commit d01066c into ZouYouShun:master Jan 11, 2019
@anteq

anteq commented Jan 11, 2019

Copy link
Copy Markdown
Author

Cool, no problem! Can we expect that to be included in the release soon?

@anteq

anteq commented Jan 18, 2019

Copy link
Copy Markdown
Author

Hey @ZouYouShun, can you estimate when you'll be able to release it onto npm? Looking forward to it since its an issue that affects our usage.

Thank you, really appreciate the work put into this library!

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