Skip to content

Instantly share code, notes, and snippets.

@drozdzynski
Last active March 31, 2018 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drozdzynski/ed0fd2d06eebc1f6c43235c7193d74c3 to your computer and use it in GitHub Desktop.
Save drozdzynski/ed0fd2d06eebc1f6c43235c7193d74c3 to your computer and use it in GitHub Desktop.
Watch node inserted, alternative to MutationOvserver
@keyframes nodeInserted {
from { opacity: 0.99; }
to { opacity: 1; }
}
.elementToWatch {
animation-duration: 0.001s;
animation-name: nodeInserted;
}
var insertListener = function(event){
if (event.animationName == "nodeInserted") {
// This is the debug for knowing our listener worked!
// event.target is the new node!
console.warn("Another node has been inserted! ", event, event.target);
}
}
document.addEventListener("animationstart", insertListener, false); // standard + firefox
document.addEventListener("MSAnimationStart", insertListener, false); // IE
document.addEventListener("webkitAnimationStart", insertListener, false); // Chrome + Safari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment