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

ResizeSensor changes layout #250

Open
Hawk5446 opened this issue Nov 19, 2018 · 1 comment
Open

ResizeSensor changes layout #250

Hawk5446 opened this issue Nov 19, 2018 · 1 comment

Comments

@Hawk5446
Copy link

First off, thanks for the great work you have given to the community.

Sample

<div id="masterKontainer" style="position:relative"> <div id="Kontainer" style="z-index:10;position:absolute;top:0;left:0;background-color:transparent;border:solid;border-color:yellow;"> </div> <div id="Kontainer2">stuff</div> </div>

In the sample above I apply ResizeSensor to element Kontainer. Without ResizeSensor the div floats above the Kontainer2. When ResizeSensor is applied, it changes the layout and moves Kontainer2 from behind Kontainer. You get the idea, my code is much more complex than above, but that was just for example.

After looking at the source, I found that everything is just fine until here

        var position = window.getComputedStyle(element).getPropertyPriority('position');
        if ('absolute' !== position && 'relative' !== position && 'fixed' !== position) {
            element.style.position = 'relative';
        }

Where the element position is changed to 'relative'. If i comment out this line it works fine. What is the purpose of this? Should I find another workaround?

@marcj
Copy link
Owner

marcj commented Nov 20, 2018

The sensor works only in an element that is not statically positioned, means either absolute, relative or fixed. The actual sensor elements (which are simple divs) need to maintain the exact same dimensions as the actual element, which works only with non statically positioned elements, so the offset of our sensor elements is the actual element you want to monitor. There no way around that.

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

2 participants