I'm trying to observe changes to the "offsetParent"-property of a div, but I can't seem to get it working.
Basically my goal is to execute a function, after offsetParent is not null.
this.element.callFunctionWhenOffsetParentChanges( _ => {
if(this.element.offsetParent){
this.doSomething();
}
});
I tried using a MutationObserver like this:
const observer = MutationObserver( _ => {
if(this.element.offsetParent){
this.doSomething();
}
});
observer.observe(this.element, {attributeFilter: ['offsetParent']})
But it doesn't trigger when the offsetParent gets set (e.g. when the element is really visible).
If necessary I can post more code, but maybe I'm just missing something in the MutationObserver or there is another way to react to the offsetParent being set.
Thanks in advance for your help!