Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created July 7, 2015 08:36
Show Gist options
  • Select an option

  • Save JavaScript-Packer/9dee8df8d56d7ab446a1 to your computer and use it in GitHub Desktop.

Select an option

Save JavaScript-Packer/9dee8df8d56d7ab446a1 to your computer and use it in GitHub Desktop.
Create animation in your web page with simple JavaScript. Simply moves up and down in a sine wave frequency. Live demo on http://jsfiddle.net/v7xr46jv/show/
document.write('<h1 id="x">WHAK.com</h1>');
var is = 0;
setInterval(function(r) {
r = document.getElementById("x");
r.style.position = "absolute";
r.style.top = 50 * Math.sin(is) + 80 + "px";
is += .05;
}, 1e3 / 30);
@JavaScript-Packer

Copy link
Copy Markdown
Author

This might work for you too @ 177 bytes:

document.write('<h1 id="x">WHAK.com</h1>');var is=0;setInterval('r=document.getElementById("x");r.style.position="absolute";r.style.top=50*Math.sin(is)+80+"px";is+=.05',1e3/30)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment