Last active
March 31, 2018 11:03
-
-
Save drozdzynski/ed0fd2d06eebc1f6c43235c7193d74c3 to your computer and use it in GitHub Desktop.
Watch node inserted, alternative to MutationOvserver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@keyframes nodeInserted { | |
from { opacity: 0.99; } | |
to { opacity: 1; } | |
} | |
.elementToWatch { | |
animation-duration: 0.001s; | |
animation-name: nodeInserted; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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