Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

add basic easing functions examples

Julian Garnierea32cbca49b5
diff --git a/examples/easings.html b/examples/easings.html
new file mode 100644
index 00000000..21c32b70
--- /dev/null
+++ b/examples/easings.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>anime.js</title>
+ <meta charset="utf-8">
+ <link rel="icon" type="image/png" href="img/favicon.png" />
+ <link rel="apple-touch-icon" href="img/apple-touch-icon.png" />
+ <link href="css/styles.css" rel="stylesheet">
+ <style>
+ section {
+ display: flex;
+ }
+ .easing {
+ flex: 1;
+ position: relative;
+ width: auto;
+ height: 100%;
+ padding: 20vh 4px 4px 4px;
+ }
+ .easing div {
+ width: 2rem;
+ height: 2rem;
+ border-radius: 50%;
+ }
+ .easing p {
+ transform: rotate(90deg) translateY(-100%);
+ transform-origin: 0 50%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
+ </style>
+</head>
+<body>
+ <script src="../anime.js"></script>
+ <script>
+
+ var sectionEl = document.querySelector('section');
+ var easingList = Object.keys(anime.easings).sort(function(a, b) {
+ return (a < b) ? -1 : (a > b) ? 1 : 0;
+ });
+
+ function createEaseEl(easeName) {
+ var el = document.createElement('div');
+ var ballEl = document.createElement('div');
+ var textEl = document.createElement('p');
+ el.classList.add(easeName);
+ el.classList.add('easing');
+ ballEl.classList.add('blue');
+ textEl.innerHTML = easeName;
+ el.appendChild(ballEl);
+ el.appendChild(textEl);
+ document.body.appendChild(el);
+ anime({
+ targets: ballEl,
+ translateY: '74vh',
+ loop: true,
+ direction: 'alternate',
+ duration: 2000,
+ easing: easeName
+ });
+ }
+
+ easingList.forEach(createEaseEl);
+
+ </script>
+</body>
+</html>