Not sure if anyone is still looking for this but I was and this is the solution I ended up using.
var __css = document.createElement("style");
__css.type = "text/css";
__css.innerHTML = '.alertInsertion {animation: __nodeInserted 0.001s !important; -o-animation: __nodeInserted 0.001s !important; -ms-animation: __nodeInserted 0.001s !important; -moz-animation: __nodeInserted 0.001s !important; -webkit-animation: __nodeInserted 0.001s !important;}'+
'@keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-moz-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-webkit-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-ms-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-o-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}';
document.body.appendChild(__css);
insertion_event = function(event){
if (event.animationName == '__nodeInserted') {
event.target.className = event.target.className.replace(/\balertInsertion\b/,'');
document.dispatchEvent(new CustomEvent('elementInserted', {'target': event.target}));
}
}
document.addEventListener('animationstart', insertion_event, false);
document.addEventListener('MSAnimationStart', insertion_event, false);
document.addEventListener('webkitAnimationStart', insertion_event, false);
Adding the class 'alertInsertion' to the css of the page with a call to the __nodeInserted animation.
if the animation is triggered it removes the class from the element and sends out a custom event called elementInserted that includes the element that triggered it.
simply use it by adding an event listener:
document.addEventListener('elementInserted', function(e)
{
//Do whatever you want with e.target here.
});
and adding the .alertInsertion class to any elements you want to trigger it.
If the element got another class with an animation it will run after this class has been removed.