<div id="container">
<h4>Content be here..</h4>
</div>
<div id="log"><p>Mutations:</p></div>
#log {
position: absolute;
top: 0;
right: 0;
width: 25vw;
min-width: 100px;
min-height: 100px;
border: 1px solid #ccc;
height: 25vh;
background-color: rgba(200,200,200,0.5);
padding: 1em;
overflow: scroll;
}
#log > div {
font-size: 0.8em;
}
const content = document.getElementById('container');
const log = document.getElementById('log');
const onMutation = events => {
const div = document.createElement('div');
div.innerText = events[0].type;
log.appendChild(div);
};
const observer = new MutationObserver(onMutation);
observer.observe(content, {subtree: true, childList: true});
let pause = 500;
const delayedAdd = () => setTimeout(() => {
const el = document.createElement('div');
el.innerText = Math.random().toString(36).substring(2, 11);
content.appendChild(el);
delayedAdd();
pause *= 1.5;
}, pause);
delayedAdd();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.