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

Use parentNode to listen, not the element itself #22

Open
dok opened this issue May 11, 2017 · 0 comments
Open

Use parentNode to listen, not the element itself #22

dok opened this issue May 11, 2017 · 0 comments

Comments

@dok
Copy link

dok commented May 11, 2017

Perhaps this is an edge case that I am seeing, but if the element has a defined height and width, the object DOM node will not detect a difference, and consequently will not trigger an event.

Here is what my DOM node looks like:

<div class="ReactTabs__TabPanel ReactTabs__TabPanel--selected" role="tabpanel" id="react-tabs-51" aria-labelledby="react-tabs-50" style="position: relative; height: 212px;">
    <div style="background: red; width: 100%; height: 100%;"></div>
    <object style="display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;" class="resize-sensor" type="text/html" data="about:blank"></object>
</div>

In this example, you can see that the root element has a height of 212px. When the parent div (not shown in this example) is dragged and resized, because the 'panel' div already has a height associated with it, it will not trigger an event.

I'd like to propose a solution: attach the object DOM node into the parentNode of the element:

// https://github.com/KyleAMathews/element-resize-event/blob/master/index.js#L73
    element.parentNode.appendChild(obj)  // line 78 & line 73

Here is what the DOM would look like after the change:

screen shot 2017-05-11 at 1 46 07 pm

Here is a screenshot with current implementation:

screen shot 2017-05-11 at 1 15 42 pm

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