Skip to content

Instantly share code, notes, and snippets.

@mygoare
Created July 9, 2014 08:17
Show Gist options
  • Save mygoare/eefb097deaaf9934192a to your computer and use it in GitHub Desktop.
Save mygoare/eefb097deaaf9934192a to your computer and use it in GitHub Desktop.
detect dom changes
<html>
<head>
<title>detect node insertion</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<style type="text/css">
@-webkit-keyframes nodeInserted
{
0% {width: 100px;}
50% {width: 200px;}
100% {width: 100px;}
}
#parentElement {
/*-webkit-animation-iteration-count: infinite;*/
-webkit-animation-duration: 1s;
-webkit-animation-name: nodeInserted;
width: 300px;
height: 100px;
background: #ccc;
transition: width 1s;
}
</style>
<div id="parentElement"></div>
<script type="text/javascript">
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.getElementById('parentElement').addEventListener("webkitAnimationStart", insertListener, false); // Chrome + Safari
document.getElementById('parentElement').addEventListener('webkitTransitionEnd', function()
{
console.warn('transition end.......');
}, false);
</script>
</body>
</html>
element.addEventListener('webkitAnimationEnd', setScrollbarRightBottomPosition);
element.addEventListener('oAnimationEnd', setScrollbarRightBottomPosition);
element.addEventListener('msAnimationEnd', setScrollbarRightBottomPosition);
element.addEventListener('animationend', setScrollbarRightBottomPosition);
http://trello-abc.stor.sinaapp.com/53ba2a4e91790597f11a95ab19c34a135c404f6e7fef6.js
http://trello-abc.stor.sinaapp.com/53ba2a930d5e2bf0839fead47bed91f6d99ee0aecb7f4.css
// Cross-Browser, Event-based, Element Resize Detection
http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment