Skip to content

adjusting rounding in getElementPosition #247

Closed
@thenewguy

Description

@thenewguy

Moved from #243 (comment)

I am observing an odd issue that I couldn't reproduce it at first... if you open the page at 100% zoom it works as expected. If you change the zoom to 110% it alternates between scrolling to y coord of 429px and 430px. This was observed at a window width between 548px and 637px according to the chrome web developer plugin. Is the use of parseInt in getElementPosition important?

Changing it to the following prevents the pixel jumping I am observing:

        function getElementPosition(target){
            var iFramePosition = target.getBoundingClientRect();

            getPagePosition(iframeId);

            return {
                x: Math.floor( Number(iFramePosition.left) + Number(pagePosition.x) ),
                y: Math.floor( Number(iFramePosition.top)  + Number(pagePosition.y) )
            };
        }

The modified getElementPosition function is demonstrated here: http://thenewguy.github.io/iframe-resizer/issues/243/6/host.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions