Skip to content
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

Negative offset #16

Open
Ryvix opened this issue May 23, 2020 · 0 comments
Open

Negative offset #16

Ryvix opened this issue May 23, 2020 · 0 comments

Comments

@Ryvix
Copy link

Ryvix commented May 23, 2020

Hi there,

Been using this in something for awhile now. Works pretty great.

However I've noticed sometimes for some reason the container has 1 pixel width and height more than the image and the image gets an offset of -0.5px for top and left which I think at some window sizes the browser will round it to move a full pixel and sometimes not which causes it to cut off the first pixel of the top and left of the image which is quite noticeable when that is a 1px border around the image.

I don't know if this is the best way to fix it or not but I found that adding Math.ceil to the layout.x and layout.y values fixed it for me. I'm wondering if maybe there is a better way somewhere else?

$element.css({position: 'absolute', top: Math.ceil(layout.y) + 'px', left: Math.ceil(layout.x) + 'px', width: layout.width + 'px', height: layout.height + 'px', 'max-width': 'none'});

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

No branches or pull requests

1 participant