developit / developit/simple-element-resize-detector

Resize detection only works in Chrome now

Open
#12 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
189
Forks
4
PR merge metrics
No merged PRs in 30d

Description

I understand that at this point, this project seems to be no longer maintained. But I just want to point out, the code seems only work in Chrome (8/2019), which makes it a bit pointless because Chrome natively supports ResizeObserver. Firefox 68 and Edge (the non-chromium one) currently doesn't support ResizeObserver and this workaround also doesn't work with the two browsers. Here is my code in case I used in incorrectly:

```html


Why it doesn't work

This is the content that will be resized.


.dummy {
width: 100%;
background: red;
position: relative;
}


const CSS = `position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;pointer-events:none;`;

function observe(element, handler) {
const frame = document.createElement('iframe');
const supportsPE =
document.documentMode < 11 && 'pointerEvents' in frame.style;

frame.style.cssText = `${CSS}${supportsPE ? '' : 'visibility:hidden;'}`;
frame.onload = () => {
frame.contentWindow.onresize = () => {
handler(element);
};
};
element.appendChild(frame);
return frame;
};

observe(document.querySelector('.dummy'), function () {
console.log('dummy: resized!');
});

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied HTML reproduction in Firefox 68 and non-Chromium Edge, then compare its behavior with Chrome. Trace the detector entry point responsible for the iframe resize callback and establish whether the issue is reproducible; done means resize notifications work in the reported browsers or their unsupported status is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.