Skip to content

Negative offset #16

@ryvix

Description

@ryvix

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions