Skip to content

Fix subpixel sizes support #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2017
Merged

Fix subpixel sizes support #204

merged 1 commit into from
Dec 22, 2017

Conversation

el-fuego
Copy link
Contributor

When you are using of non-integer values for the sizes, offsetWidth can be differ per each element in a list

// What was used
$$('.item').map(i => i.offsetWidth)
(8) [199, 200, 199, 199, 199, 200, 199, 199]

// Computed css styles
$$('.item').map(i => i.style.width)
(8) ["199.5px", "199.5px", "199.5px", "199.5px", "199.5px", "199.5px", "199.5px", "199.5px"]

// BoundingClientRect
$$('.item').map(i => i.getBoundingClientRect().width)
(8) [199.5, 199.5, 199.5, 199.5, 199.5, 199.5, 199.5, 199.5]

Compatibility: https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

@marcj
Copy link
Owner

marcj commented Dec 22, 2017

Do you know why the browser engine sometimes returns 199 and sometimes 200 in offsetWidth for a value of 199.5?

@el-fuego
Copy link
Contributor Author

Probably, a bug or trying of use the same summ result as the container offsetWidth

@marcj marcj merged commit 072a3fc into marcj:master Dec 22, 2017
@marcj
Copy link
Owner

marcj commented Dec 22, 2017

Ok cool, thanks!

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