Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Improve ease visualizer

Julian Garnier09fe06f3e968
diff --git a/examples/ease-visualizer.html b/examples/ease-visualizer.html
new file mode 100644
index 00000000..807ed86e
--- /dev/null
+++ b/examples/ease-visualizer.html
@@ -0,0 +1,259 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Ease visualizer | anime.js</title>
+ <meta charset="utf-8">
+ <link rel="icon" type="image/png" href="assets/img/favicon.png" />
+ <link href="assets/css/styles.css" rel="stylesheet">
+ <script src="../anime.js"></script>
+ <style>
+ .easings {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ flex-direction: column;
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ }
+ .output {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ position: relative;
+ width: 100%;
+ height: 400px;
+ }
+ .options {
+ display: flex;
+ flex-wrap: wrap;
+ flex-direction: row;
+ width: 100%;
+ min-height: 300px;
+ border-top: 1px solid #09090B;
+ }
+ .grid {
+ border-top: 1px solid rgba(255,255,255,0.2);
+ border-right: 1px solid rgba(255,255,255,0.2);
+ background: linear-gradient(0deg, rgba(255,255,255,0.2) 1px, rgba(0,0,0,0) 1px),
+ linear-gradient(90deg, rgba(255,255,255,0.2) 1px, rgba(0,0,0,0) 1px),
+ linear-gradient(0deg, rgba(255,255,255,0.1) 1px, rgba(0,0,0,0) 1px),
+ linear-gradient(90deg, rgba(255,255,255,0.1) 1px, rgba(0,0,0,0) 1px);
+ background-position: 0px -1px;
+ background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
+ }
+ .visualizer-wrapper {
+ width: 200px;
+ height: 200px;
+ }
+ .visualizer {
+ position: relative;
+ width: 100px;
+ height: 100px;
+ transform: scale(2);
+ transform-origin: 0 0;
+ }
+ .value {
+ width: 20px;
+ height: 200px;
+ margin-left: 10px;
+ }
+ @media screen and (min-width: 980px) {
+ .easings {
+ flex-direction: row;
+ }
+ .output {
+ width: 50%;
+ height: 100%;
+ }
+ .options {
+ width: 50%;
+ height: 100%;
+ }
+ .visualizer-wrapper {
+ width: 400px;
+ height: 400px;
+ }
+ .visualizer {
+ transform: scale(4);
+ }
+ .value {
+ width: 40px;
+ height: 400px;
+ margin-left: 20px;
+ }
+ }
+ .ball {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 10px;
+ height: 10px;
+ margin: -5px 0 0 -5px;
+ background: #FF1461;
+ border-radius: 50%;
+ }
+ .square {
+ position: absolute;
+ z-index: 0;
+ top: 0;
+ left: 100%;
+ width: 10px;
+ height: 1px;
+ margin: -1px 0 0 5px;
+ background: #5A87FF;
+ }
+ svg {
+ overflow: visible;
+ position: relative;
+ z-index: 1;
+ width: 100%;
+ height: 100%;
+ }
+ path {
+ fill: none;
+ stroke: #18FF92;
+ }
+ button {
+ opacity: 1;
+ position: relative;
+ color: currentColor;
+ font-size: 16px;
+ width: calc(25% + 1px);
+ border: 1px solid #09090B;
+ background: transparent;
+ margin: -1px 0 0 -1px;
+ }
+ label {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: calc(100% + 1px);
+ margin: -1px 0 0 -1px;
+ border-top: 0px;
+ border-left: 1px solid #09090B;
+ border-right: 1px solid #09090B;
+ color: rgba(255,255,255,.3);
+ }
+ button.active {
+ color: #18FF92;
+ z-index: 1;
+ opacity: 1;
+ border: 1px solid currentColor;
+ background: #222027;
+ }
+ button:focus {
+ outline: none;
+ }
+ button:hover {
+ background: #222027;
+ }
+ </style>
+</head>
+<body>
+ <div class="easings">
+ <div class="output">
+ <div class="visualizer-wrapper grid">
+ <div class="visualizer">
+ <div class="ball"></div>
+ <div class="square"></div>
+ <svg viewBox="0 0 100 100">
+ <path class="curve"/>
+ </svg>
+ </div>
+ </div>
+ <div class="value grid"></div>
+ </div>
+ <div class="options">
+ <label>Ease In</label>
+ <button class="active" value="0.550, 0.085, 0.680, 0.530">Quad</button>
+ <button value="0.550, 0.055, 0.675, 0.190">Cubic</button>
+ <button value="0.895, 0.030, 0.685, 0.220">Quart</button>
+ <button value="0.755, 0.050, 0.855, 0.060">Quint</button>
+ <button value="0.470, 0.000, 0.745, 0.715">Sine</button>
+ <button value="0.950, 0.050, 0.795, 0.035">Expo</button>
+ <button value="0.600, 0.040, 0.980, 0.335">Circ</button>
+ <button value="0.600, -0.280, 0.735, 0.045">Back</button>
+ <label>Ease Out</label>
+ <button value="0.250, 0.460, 0.450, 0.940">Quad</button>
+ <button value="0.215, 0.610, 0.355, 1.000">Cubic</button>
+ <button value="0.165, 0.840, 0.440, 1.000">Quart</button>
+ <button value="0.230, 1.000, 0.320, 1.000">Quint</button>
+ <button value="0.390, 0.575, 0.565, 1.000">Sine</button>
+ <button value="0.190, 1.000, 0.220, 1.000">Expo</button>
+ <button value="0.075, 0.820, 0.165, 1.000">Circ</button>
+ <button value="0.175, 0.885, 0.320, 1.275">Back</button>
+ <label>Ease In Out</label>
+ <button value="0.455, 0.030, 0.515, 0.955">Quad</button>
+ <button value="0.645, 0.045, 0.355, 1.000">Cubic</button>
+ <button value="0.770, 0.000, 0.175, 1.000">Quart</button>
+ <button value="0.860, 0.000, 0.070, 1.000">Quint</button>
+ <button value="0.445, 0.050, 0.550, 0.950">Sine</button>
+ <button value="1.000, 0.000, 0.000, 1.000">Expo</button>
+ <button value="0.785, 0.135, 0.150, 0.860">Circ</button>
+ <button value="0.680, -0.550, 0.265, 1.550">Back</button>
+ </div>
+ </div>
+ <script>
+
+ var pathEl = document.querySelector('.curve');
+ var presetsEls = document.querySelectorAll('.options button');
+
+ function convertCoordinates(coords) {
+ var x1 = coords[0] * 100;
+ var y1 = 100 - (coords[1] * 100);
+ var x2 = coords[2] * 100;
+ var y2 = 100 - (coords[3] * 100);
+ return 'M0 100C' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2 + ' 100 0';
+ }
+
+ function getCoordinates(value) {
+ return convertCoordinates(value.split(','));
+ }
+
+ function changeEase(event) {
+ for (var i = 0; i < presetsEls.length; i++) {
+ presetsEls[i].classList.remove('active');
+ }
+ var buttonEl = event.target;
+ var value = buttonEl.value;
+ buttonEl.classList.add('active');
+ var coordinates = getCoordinates(value);
+ anime.remove(pathEl);
+ anime({
+ targets: pathEl,
+ d: coordinates
+ });
+ }
+
+ for (var i = 0; i < presetsEls.length; i++) {
+ presetsEls[i].onclick = changeEase;
+ }
+
+ pathEl.setAttribute('d', getCoordinates(presetsEls[0].value));
+
+ var path = anime.path(pathEl, 120);
+
+ var ball = anime({
+ targets: '.ball',
+ translateX: path('x'),
+ translateY: path('y'),
+ easing: 'linear',
+ delay: 200,
+ loop: true,
+ direction: 'alternate'
+ });
+
+ var square = anime({
+ targets: '.square',
+ translateY: path('y'),
+ easing: 'linear',
+ delay: 200,
+ loop: true,
+ direction: 'alternate'
+ });
+
+ </script>
+</body>
+</html>
diff --git a/examples/easings-visualizer.html b/examples/easings-visualizer.html
deleted file mode 100644
index 9b8cd2f5..00000000
--- a/examples/easings-visualizer.html
+++ /dev/null
@@ -1,192 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Easing visualizer | anime.js</title>
- <meta charset="utf-8">
- <link rel="icon" type="image/png" href="assets/img/favicon.png" />
- <link href="assets/css/styles.css" rel="stylesheet">
- <script src="../anime.js"></script>
- <style>
- .easings {
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- width: 100%;
- height: 100%;
- }
- .visualizer-wrapper {
- position: relative;
- width: 600px;
- padding: 50px 100px;
- }
- .visualizer {
- position: relative;
- width: 100px;
- height: 100px;
- transform: scale(4);
- transform-origin: 0 50%;
- }
- .ball {
- position: absolute;
- top: 0;
- left: 0;
- width: 10px;
- height: 10px;
- margin: -5px 0 0 -5px;
- background: #FF1461;
- border-radius: 50%;
- }
- .square {
- position: absolute;
- top: 50%;
- left: 0;
- width: 10px;
- height: 10px;
- margin: -5px 0 0 -5px;
- background: #5A87FF;
- }
- svg {
- overflow: visible;
- width: 100%;
- height: 100%;
- }
- path {
- fill: none;
- stroke: #18FF92;
- }
- .options {
- display: flex;
- flex-wrap: wrap;
- flex-direction: row;
- width: 500px;
- height: 500px;
- color: #18FF92;
- border-left: 1px solid #173B2F;
- border-top: 1px solid #173B2F;
- }
- button {
- opacity: .2;
- position: relative;
- color: currentColor;
- font-size: 16px;
- width: calc(25% + 1px);
- border-right: 1px solid currentColor;
- border-bottom: 1px solid currentColor;
- border-left: 1px solid #17151C;
- border-top: 1px solid #17151C;
- background: #17151C;
- margin: -1px 0 0 -1px;
- }
- button.active {
- z-index: 1;
- opacity: 1;
- border: 1px solid currentColor;
- }
- button:focus {
- outline: none;
- }
- </style>
-</head>
-<body>
- <div class="easings">
- <div class="visualizer-wrapper">
- <div class="visualizer">
- <div class="ball"></div>
- <div class="square"></div>
- <svg viewBox="0 0 100 100">
- <path class="curve"/>
- </svg>
- </div>
- </div>
- <div class="options">
- <button value="0.550, 0.085, 0.680, 0.530">In Quad</button>
- <button value="0.550, 0.055, 0.675, 0.190">In Cubic</button>
- <button value="0.895, 0.030, 0.685, 0.220">In Quart</button>
- <button value="0.755, 0.050, 0.855, 0.060">In Quint</button>
- <button value="0.470, 0.000, 0.745, 0.715">In Sine</button>
- <button value="0.950, 0.050, 0.795, 0.035">In Expo</button>
- <button value="0.600, 0.040, 0.980, 0.335">In Circ</button>
- <button value="0.600, -0.280, 0.735, 0.045">In Back</button>
- <button value="0.250, 0.460, 0.450, 0.940">Out Quad</button>
- <button value="0.215, 0.610, 0.355, 1.000">Out Cubic</button>
- <button value="0.165, 0.840, 0.440, 1.000">Out Quart</button>
- <button value="0.230, 1.000, 0.320, 1.000">Out Quint</button>
- <button value="0.390, 0.575, 0.565, 1.000">Out Sine</button>
- <button value="0.190, 1.000, 0.220, 1.000">Out Expo</button>
- <button value="0.075, 0.820, 0.165, 1.000">Out Circ</button>
- <button value="0.175, 0.885, 0.320, 1.275">Out Back</button>
- <button value="0.455, 0.030, 0.515, 0.955">In Out Quad</button>
- <button value="0.645, 0.045, 0.355, 1.000">In Out Cubic</button>
- <button value="0.770, 0.000, 0.175, 1.000">In Out Quart</button>
- <button value="0.860, 0.000, 0.070, 1.000">In Out Quint</button>
- <button value="0.445, 0.050, 0.550, 0.950">In Out Sine</button>
- <button value="1.000, 0.000, 0.000, 1.000">In Out Expo</button>
- <button value="0.785, 0.135, 0.150, 0.860">In Out Circ</button>
- <button value="0.680, -0.550, 0.265, 1.550">In Out Back</button>
- </div>
- </div>
- <script>
-
- var ballEl = document.querySelector('.ball');
- var pathEl = document.querySelector('.curve');
- var presetsEls = document.querySelectorAll('.options button');
-
- function convertCoordinates(coords) {
- var x1 = coords[0] * 100;
- var y1 = 100 - (coords[1] * 100);
- var x2 = coords[2] * 100;
- var y2 = 100 - (coords[3] * 100);
- return 'M0 100C' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2 + ' 100 0';
- }
-
- function getCoordinates(value) {
- return convertCoordinates(value.split(','));
- }
-
- function changeEasing(event) {
- for (var i = 0; i < presetsEls.length; i++) {
- presetsEls[i].classList.remove('active');
- }
- var buttonEl = event.target;
- var value = buttonEl.value;
- buttonEl.classList.add('active');
- var coordinates = getCoordinates(value);
- anime.remove(pathEl);
- anime({
- targets: pathEl,
- d: coordinates
- });
- }
-
- for (var i = 0; i < presetsEls.length; i++) {
- presetsEls[i].onclick = changeEasing;
- }
-
- pathEl.setAttribute('d', getCoordinates(presetsEls[0].value));
-
- var path = anime.path('path', 120);
-
- var ball = anime({
- targets: '.ball',
- translateX: path('x'),
- translateY: path('y'),
- easing: 'linear',
- delay: 200,
- loop: true,
- direction: 'alternate'
- });
-
- var square = anime({
- targets: '.square',
- translateX: path('x'),
- easing: 'linear',
- delay: 200,
- loop: true,
- direction: 'alternate'
- });
-
- </script>
- <script src="assets/js/stats.js"></script>
-</body>
-</html>