Skip to content

Instantly share code, notes, and snippets.

@uolcano
Last active March 23, 2017 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uolcano/15f61be11e32432c9d73a2d8601f9cf8 to your computer and use it in GitHub Desktop.
Save uolcano/15f61be11e32432c9d73a2d8601f9cf8 to your computer and use it in GitHub Desktop.
gist test on bl.ocks.org
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>bl.ocks.org rendering test</title>
<script src="http://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="ball"></div>
<script type="text/javascript">
window.jQuery || document.write("<script src=\"http://code.jquery.com/jquery-2.2.4.min.js\" integrity=\"sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=\" crossorigin=\"anonymous\"><\/script>");
</script>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
$(document).ready(function() {
$('.ball').click(function() {
console.log(this.className);
$(this).toggleClass('paused');
});
$(window).load(function() {
alert('click the ball to control the running state.');
});
});
/* Reset */
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
/* Animation */
.ball {
width: 50px;
height: 50px;
position: absolute;
top: 0;
left: 0;
z-index: 99;
border-radius: 50%;
background: #fa0;
transition: background 1s ease;
animation: 7s 0s xmove, 5s 0s ymove;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
@keyframes xmove {
0% {left: 0;}
100% {left: calc(100% - 50px);}
}
@keyframes ymove {
0% {top: 0;}
100% {top: calc(100% - 50px);}
}
.ball:hover {
background: #1af;
}
.paused{
animation-play-state: paused;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment