alexdunphy / units

Got units? Convert them! Parse length, angle and resolution CSS values and convert between units.
MIT License
26 stars 7 forks source link

offsetWidth and offsetHeight as fourth argument #5

Open vitorinoninja opened 6 years ago

vitorinoninja commented 6 years ago

Hello! Thank you for your module.

I noticed useSelf was false when using those properties as fourth argument:

units.convert("px", "10%", myElement, "offsetWidth")

This was generating wrong results, since the parent offsetWidth can be different (if myElement as visible scroll, in exemple).

At least in all scenarios I am using, this fix made things work properly. It was fun to read your code and I hope my little change helps somehow!