en.javascript.info/3-animation/3-js-animation/elastic.view/index.html
Ilya Kantor 455d300d8d renames
2017-05-25 11:56:32 +03:00

34 lines
No EOL
637 B
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<script src="https://js.cx/libs/animate.js"></script>
</head>
<body>
<div id="path">
<div id="brick"></div>
</div>
<script>
brick.onclick = function() {
animate({
duration: 3000,
timing: function elastic(x, timeFraction) {
return Math.pow(2, 10 * (timeFraction - 1)) * Math.cos(20 * Math.PI * x / 3 * timeFraction)
}.bind(null, 1.5),
draw: function(progress) {
brick.style.left = progress * 500 + 'px';
}
});
};
</script>
</body>
</html>