Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Update examples

Julian Garnierd2702b8d4576
diff --git a/documentation/assets/css/animejs.css b/documentation/assets/css/animejs.css
new file mode 100644
index 00000000..e38fa5c3
--- /dev/null
+++ b/documentation/assets/css/animejs.css
@@ -0,0 +1,49 @@
+:root {
+ font-size: 24px;
+}
+
+*, *:before, *:after {
+ box-sizing: border-box;
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+}
+
+html,
+body {
+ background-color: #F6F4F2;
+ color: #373535;
+}
+
+body {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ font-family: RoobertTRIAL-Regular, Helvetica Neue, Helvetica, Arial, sans-serif;
+ font-variant-numeric: tabular-nums;
+ -webkit-font-smoothing: antialiased;
+ overflow-x: hidden;
+}
+
+input {
+ font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
+ font-variant-numeric: tabular-nums;
+}
+
+.color-white { color: #F6F4F2; } /* Black */
+.color-black { color: #373535; } /* Black */
+.color-red, .color-targets { color: #F64E4D; } /* Red */
+.color-orange, .color-properties { color: #F6984E; } /* Orange */
+.color-yellow, .color-prop-params { color: #C8CB48; } /* Yellow */
+.color-citrus, .color-anim-params { color: #EECD4F; } /* Citrus */
+.color-green, .color-values { color: #98C762; } /* Green */
+.color-darkgreen, .color-tl { color: #56BD9C; } /* Darkgreen */
+.color-turquoise, .color-controls { color: #53D3D3; } /* Turquoise */
+.color-skyblue, .color-states { color: #6AAAE1; } /* Skyblue */
+.color-kingblue, .color-callbacks { color: #6A7BE0; } /* Kingblue */
+.color-lavender, .color-svg { color: #86589E; } /* Lavender */
+.color-purple, .color-easings { color: #D758A0; } /* Purple */
+.color-pink, .color-helpers { color: #F07B8E; } /* Pink */
\ No newline at end of file
diff --git a/documentation/assets/img/icons/favicon.png b/documentation/assets/img/icons/favicon.png
index ab83b420..168ec7f8 100644
Binary files a/documentation/assets/img/icons/favicon.png and b/documentation/assets/img/icons/favicon.png differ
diff --git a/documentation/examples/anime-advanced-staggering.html b/documentation/examples/advanced-staggering.html
similarity index 80%
rename from documentation/examples/anime-advanced-staggering.html
rename to documentation/examples/advanced-staggering.html
index d558225c..49f79714 100644
--- a/documentation/examples/anime-advanced-staggering.html
+++ b/documentation/examples/advanced-staggering.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>stagger | anime.js</title>
+ <title>advanced staggering • anime.js</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:title" content="anime.js">
@@ -15,19 +15,14 @@
<meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">
<link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >
- <link href="../assets/css/documentation.css" rel="stylesheet">
+ <link href="../assets/css/animejs.css" rel="stylesheet">
<style>
- :root {
- font-size: 20px;
- }
-
body {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
- background-color: #F6F4F2;
}
.stagger-visualizer {
@@ -42,13 +37,10 @@
.stagger-visualizer .dot {
position: relative;
- width: .2rem;
- height: .2rem;
- margin: .4rem;
- /*border: 2px solid currentColor;*/
- /*background-color: #F6F4F2;*/
+ width: .25rem;
+ height: .25rem;
+ margin: .375rem;
background-color: currentColor;
- color: #373535;
border-radius: 50%;
}
@@ -59,7 +51,6 @@
left: 0;
width: 1rem;
height: 1rem;
- color: #FF4B4B;
background-color: currentColor;
border-radius: 50%;
}
@@ -69,7 +60,7 @@
<body>
<div class="stagger-visualizer">
- <div class="cursor"></div>
+ <div class="cursor color-red"></div>
</div>
</body>
@@ -93,11 +84,12 @@
let nextIndex = 0;
function animateGrid() {
+
nextIndex = anime.random(0, 256);
+
anime.setValue('.cursor', {
translateX: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'x'}),
- translateY: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'y'}),
- scale: 1
+ translateY: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'y'})
});
anime.timeline({
easing: 'easeInOutQuad',
@@ -110,7 +102,7 @@
{ scale: 1.125 },
{ scale: 1 }
],
- duration: 1000
+ duration: 600
})
.add({
targets: '.dot',
@@ -118,28 +110,26 @@
{
translateX: anime.stagger('-.175rem', {grid: [16, 16], from: index, axis: 'x'}),
translateY: anime.stagger('-.175rem', {grid: [16, 16], from: index, axis: 'y'}),
- duration: 300
- },
- {
+ duration: 200
+ }, {
translateX: anime.stagger('.125rem', {grid: [16, 16], from: index, axis: 'x'}),
translateY: anime.stagger('.125rem', {grid: [16, 16], from: index, axis: 'y'}),
- scale: 2.5,
- duration: 500
+ scale: 2,
+ duration: 400
}, {
translateX: 0,
translateY: 0,
scale: 1,
- duration: 600,
+ duration: 500,
}
],
delay: anime.stagger(50, {grid: [16, 16], from: index})
- }, '-=1000')
+ }, '-=600')
.add({
targets: '.cursor',
- translateX: anime.stagger('-1rem', {grid: [16, 16], from: nextIndex, axis: 'x'}),
- translateY: anime.stagger('-1rem', {grid: [16, 16], from: nextIndex, axis: 'y'}),
- duration: 800,
- easing: 'easeOutQuad'
+ translateX: { value: anime.stagger('-1rem', {grid: [16, 16], from: nextIndex, axis: 'x'}), duration: anime.random(400, 1200) },
+ translateY: { value: anime.stagger('-1rem', {grid: [16, 16], from: nextIndex, axis: 'y'}), duration: anime.random(400, 1200) },
+ easing: 'easeOutSine'
}, '-=1100')
index = nextIndex;
diff --git a/documentation/examples/built-in-easings.html b/documentation/examples/built-in-easings.html
new file mode 100644
index 00000000..ee38f875
--- /dev/null
+++ b/documentation/examples/built-in-easings.html
@@ -0,0 +1,119 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>built-in easings • anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <meta property="og:title" content="anime.js">
+ <meta property="og:url" content="http://animejs.com">
+ <meta property="og:description" content="Javascript Animation Engine">
+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">
+ <meta name="twitter:card" content="summary">
+ <meta name="twitter:title" content="anime.js">
+ <meta name="twitter:site" content="@juliangarnier">
+ <meta name="twitter:description" content="Javascript Animation Engine">
+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">
+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">
+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >
+ <link href="../assets/css/animejs.css" rel="stylesheet">
+ <style>
+
+ body {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .easing-visualizer {
+ position: relative;
+ display: flex;
+ align-items: center;
+ width: 16rem;
+ height: 16rem;
+ }
+
+ .easing-visualizer .bar {
+ width: 2px;
+ height: 4px;
+ background-color: currentColor;
+ transform-origin: 50% 50%;
+ }
+
+ .easing-visualizer .bar:not(:last-child) {
+ margin-right: 4px;
+ }
+
+ .easing-visualizer .dot {
+ position: absolute;
+ width: 8px;
+ height: 8px;
+ margin-left: -3px;
+ background-color: currentColor;
+ border-radius: 50%;
+ }
+
+ </style>
+</head>
+<body>
+
+ <div class="easing-visualizer">
+ </div>
+
+</body>
+<script type="module">
+
+ import anime from '../../src/index.js';
+
+ const easingVisualizerEl = document.querySelector('.easing-visualizer');
+ const fragment = document.createDocumentFragment();
+ const numberOfBars = 63;
+
+ for (let i = 0; i < numberOfBars; i++) {
+ const barEl = document.createElement('div');
+ const dotEl = document.createElement('div');
+ barEl.classList.add('bar');
+ dotEl.classList.add('dot');
+ dotEl.classList.add('color-red');
+ fragment.appendChild(barEl);
+ fragment.appendChild(dotEl);
+ }
+
+ easingVisualizerEl.appendChild(fragment);
+
+ anime.setValue('.easing-visualizer .dot', { translateX: anime.stagger(6) });
+
+ function animateEasing() {
+
+ const easings = [];
+ for (let ease in anime.penner) easings.push(ease);
+ easings.push('steps('+anime.random(5, 20)+')');
+ easings.push('cubicBezier(0.545, 0.475, 0.145, 1)');
+ const ease = easings[anime.random(0, easings.length - 1)];
+ const duration = 450;
+
+ anime.timeline({
+ easing: 'easeInOutQuad',
+ complete: animateEasing
+ })
+ .add({
+ targets: '.easing-visualizer .bar',
+ scaleY: anime.stagger([1, 88], {easing: ease, from: 'center', direction: 'reverse'}),
+ easing: ease,
+ duration: duration,
+ delay: anime.stagger(16, {from: 'center'})
+ })
+ .add({
+ targets: '.easing-visualizer .dot',
+ translateY: anime.stagger(['-6rem', '6rem'], {easing: ease, from: 'last'}),
+ easing: ease,
+ duration: duration,
+ delay: anime.stagger(8, {from: 'center'})
+ }, 0);
+
+ }
+
+ animateEasing();
+
+</script>
+</html>
diff --git a/documentation/examples/anime-easings.html b/documentation/examples/time-control.html
similarity index 52%
rename from documentation/examples/anime-easings.html
rename to documentation/examples/time-control.html
index 79e02413..0fb76ce1 100644
--- a/documentation/examples/anime-easings.html
+++ b/documentation/examples/time-control.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>stagger | anime.js</title>
+ <title>time control • anime.js</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:title" content="anime.js">
@@ -15,7 +15,7 @@
<meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">
<link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >
- <link href="../assets/css/documentation.css" rel="stylesheet">
+ <link href="../assets/css/animejs.css" rel="stylesheet">
<style>
body {
@@ -23,63 +23,51 @@
flex-wrap: wrap;
justify-content: center;
align-items: center;
- background-color: #F6F4F2;
}
- .easing-visualizer {
+ .time-control {
+ position: relative;
display: flex;
- justify-content: space-between;
- align-items: flex-end;
- width: 400px;
- height: 400px;
+ flex-wrap: wrap;
+ justify-content: center;
+ align-items: center;
+ width: 36rem;
+ height: 24rem;
}
- .easing-visualizer div {
- width: 2px;
- height: 2px;
- margin: 0 0 0 0;
- background-color: #373535;
- transform-origin: 50% 100%;
+ .time-control .timeline {
+
}
</style>
</head>
<body>
- <div class="easing-visualizer"></div>
+ <div class="time-control">
+ <div class="timeline"></div>
+ </div>
</body>
<script type="module">
import anime from '../../src/index.js';
- const easingVisualizerEl = document.querySelector('.easing-visualizer');
+ const staggerVisualizerEl = document.querySelector('.time-control');
const fragment = document.createDocumentFragment();
- const numberOfElements = 51;
+ const numberOfElements = 256;
for (let i = 0; i < numberOfElements; i++) {
- fragment.appendChild(document.createElement('div'));
+ const dotEl = document.createElement('div');
+ dotEl.classList.add('dot');
+ fragment.appendChild(dotEl);
}
- easingVisualizerEl.appendChild(fragment);
+ staggerVisualizerEl.appendChild(fragment);
- const easings = [];
- for (let ease in anime.penner) easings.push(ease);
- easings.push('steps(10)');
- easings.push('cubicBezier(0.545, 0.475, 0.145, 1)');
+ let index = anime.random(0, 256);
+ let nextIndex = 0;
- anime({
- targets: '.easing-visualizer div',
- scaleY: (() => {
- const keyframes = easings.map(ease => { return {value: anime.stagger([1, 200], {easing: ease}), easing: ease}; });
- keyframes.push({ value: 1 });
- return keyframes;
- })(),
- delay: anime.stagger(15),
- easing: 'easeInOutSine',
- duration: 16000,
- loop: true
- });
+ animateGrid();
</script>
</html>