ZouYouShun / ngx-hm-carousel

a light carousel for Angular18+, support mobile touch by hammerJs
https://stackblitz.com/edit/stackblitz-starters-nkd5pk?file=src%2Fmain.ts
MIT License
60 stars 10 forks source link

Fix rounding error when calculating element width #17

Closed anteq closed 5 years ago

anteq commented 5 years ago

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

ZouYouShun commented 5 years ago

Thanks a lot, @anteq

anteq commented 5 years ago

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

anteq commented 5 years ago

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!