Skip to content

Instantly share code, notes, and snippets.

@krisdante
Created June 9, 2016 20:12
Show Gist options
  • Save krisdante/e8ea33e9a3cbc7ece07503d81bad6d75 to your computer and use it in GitHub Desktop.
Save krisdante/e8ea33e9a3cbc7ece07503d81bad6d75 to your computer and use it in GitHub Desktop.
(function() {
var body=document.getElementsByTagName('body').item(0);
var goLeft = 1;
var ih = body.innerHTML;
ih = '<img src="https://s-media-cache-ak0.pinimg.com/originals/7a/3d/8d/7a3d8d337b1e0f257ba2eb75a6bf355e.gif" class="ux-hen" style="visibility: hidden">' + ih;
body.innerHTML = ih;
var kura = document.getElementsByClassName('ux-hen').item(0);
kura.style.position='fixed';
kura.style.width='100px';
kura.style.bottom='20px';
kura.style.zIndex=10000000;
kura.style.right='20px';
kura.style.visibility='visible';
kura.style.transition='right 3s, width 2s';
function move() {
var next =(Math.random()*100).toFixed();
if(Math.random()>0.5) {
if(goLeft > 0) {
kura.style.transform='scale(-1,1)';
goLeft = -1;
} else {
kura.style.transform='scale(1,1)';
goLeft = 1;
}
}
var newPos = (Number.parseInt(kura.style.right) + (goLeft * next));
if (newPos < 20) {
newPos=20;
}
console.log(newPos + "px");
kura.style.right=newPos + "px";
console.log(kura.style.right);
}
setInterval(move, 3000);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment