Skip to content

Instantly share code, notes, and snippets.

@xerosanyam
Created September 14, 2022 10:39
Show Gist options
  • Save xerosanyam/ea3bd9c1f95978ff6011b6aaf0a5d941 to your computer and use it in GitHub Desktop.
Save xerosanyam/ea3bd9c1f95978ff6011b6aaf0a5d941 to your computer and use it in GitHub Desktop.
fixed not working? try this snippet
const selector = '.the-fixed-child';
function findCulprits(elem) {
if (!elem) {
throw new Error(
'Could not find element with that selector'
);
}
let parent = elem.parentElement;
while (parent) {
const {
transform,
willChange
} = getComputedStyle(parent);
if (transform !== 'none' || willChange === 'transform') {
console.warn(
'🚨 Found a culprit! 🚨\n',
parent,
{ transform, willChange }
);
}
parent = parent.parentElement;
}
}
findCulprits(document.querySelector(selector));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment