Anonymous

MediaWiki:Common.js: Difference between revisions

From Melvor Idle
Sticky headers: Try ResizeObserver instead of MutationObserver (cannot observe a computed style change)
(Sticky headers: Try using mutation observers, as on load events don't resolve the issue (they fire after the issue occurs?))
(Sticky headers: Try ResizeObserver instead of MutationObserver (cannot observe a computed style change))
Line 524: Line 524:
function setStickyHeaderTop(addObservers) {
function setStickyHeaderTop(addObservers) {
var observer = null;
var observer = null;
var observerCfg = { attributes: true, childList: false, subtree: false };
if ((addObservers) && (ResizeObserver !== undefined)) {
if (addObservers) {
observer = new ResizeObserver(
observer = new MutationObserver(
function(entries) {
function(mutationList, observer) {
setStickyHeaderTop(false);
for (var i = 0; i < mutationList.length; i++) {
var mutation = mutationList[i];
if ((mutation.type === 'attributes') && (mutation.attributeName === 'offsetHeight')) {
setStickyHeaderTop(false);
}
}
});
});
}
}
Line 549: Line 543:
firstHeight = firstRow[0].offsetHeight;
firstHeight = firstRow[0].offsetHeight;
if (addObservers) {
if (addObservers) {
observer.observe(firstRow[0], observerCfg);
observer.observe(firstRow[0]);
}
}
var firstHeaders = firstRow[0].getElementsByTagName('th');
var firstHeaders = firstRow[0].getElementsByTagName('th');