Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Update docs

Julian Garnier70ea16d39681
diff --git a/documentation/assets/css/documentation.css b/documentation/assets/css/documentation.css
index fd46c4ae..28ee8f48 100644
--- a/documentation/assets/css/documentation.css
+++ b/documentation/assets/css/documentation.css
@@ -86,6 +86,15 @@ h2 {
font-weight: 200;
}
+.description-header a {
+ text-decoration: none;
+ color: inherit;
+}
+
+.description-header a:hover {
+ text-decoration: underline;
+}
+
/* Panes */
.pane {
@@ -218,7 +227,7 @@ h2 {
}
.demo-info code {
- font-family: "Input Mono Reg", monospace;
+ font-family: "InputMono", "Courier New", Courier, monospace;
font-size: 14px;
line-height: 22px;
white-space: pre-wrap;
diff --git a/documentation/assets/css/v4.css b/documentation/assets/css/v4.css
new file mode 100644
index 00000000..02498d9e
--- /dev/null
+++ b/documentation/assets/css/v4.css
@@ -0,0 +1,186 @@
+/* V4 */
+
+body {
+ transition: padding-top .5s ease-in-out;
+}
+
+body.has-banner {
+ padding-top: 60px;
+}
+
+#top-banner,
+#docs-header {
+ transition: transform .5s ease-in-out;
+}
+
+body.has-banner #docs-header {
+ transform: translateY(60px);
+}
+
+body.has-banner #top-banner {
+ transform: translateY(0%);
+}
+
+#top-banner {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ position: fixed;
+ z-index: 99;
+ top: 0;
+ left: 0;
+ right: 0;
+ height: 60px;
+ padding-left: 60px;
+ padding-right: 10px;
+ font-size: 16px;
+ font-weight: 600;
+ background-color: #F74F4D;
+ color: #FFFFFF;
+ transform: translateY(-100%);
+}
+
+#top-banner p {
+ margin-top: -2px;
+}
+
+#close-banner {
+ position: absolute;
+ z-index: 99;
+ left: 10px;
+ top: 10px;
+ height: 40px;
+ width: 40px;
+ text-align: center;
+ background-color: transparent;
+ color: #FFF;
+ cursor: pointer;
+}
+
+#banner-cta {
+ display: inline-flex;
+ align-items: baseline;
+ height: 30px;
+ padding-left: 12px;
+ padding-right: 12px;
+ margin-left: 16px;
+ border-radius: 16px;
+ white-space: pre;
+ font-weight: 600;
+ line-height: 30px;
+ background-color: #FFF;
+ color: #F74F4D;
+ text-decoration: none;
+ transition: transform .25s ease;
+}
+
+#banner-cta:hover {
+ transform: scale(1.08);
+}
+
+@media (max-width: 640px) {
+ #top-banner {
+ padding-left: 40px;
+ padding-right: 10px;
+ font-size: 15px;
+ }
+
+ #close-banner {
+ left: 0;
+ height: 40px;
+ width: 40px;
+ }
+
+ #banner-cta {
+ margin-left: 10px;
+ }
+
+ #banner-cta span {
+ display: none;
+ }
+}
+
+/* Sponsors */
+
+.sponsor-logo {
+ opacity: .5;
+ text-decoration: none;
+ transition: opacity .25s ease;
+ margin-bottom: 20px;
+}
+
+.sponsor-logo:hover {
+ opacity: 1;
+}
+
+.sponsor-logo img {
+ width: 100%;
+ max-width: 92px;
+ height: auto;
+ margin-bottom: 10px;
+}
+
+.sponsor-name {
+ display: block;
+ color: #FFF;
+ font-family: "InputMono", "Courier New", Courier, monospace;
+ font-weight: bold;
+ font-size: 10px;
+ text-align: center;
+ letter-spacing: -.075em;
+}
+
+.sponsors-pane {
+ display: none;
+}
+
+@media (min-width: 800px) {
+ .sponsors-pane {
+ width: 148px;
+ overflow-y: scroll;
+ display: block;
+ border-left: 1px solid rgba(0,0,0,.65);
+ }
+}
+
+#docs-sponsors-list {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ padding: 20px;
+}
+
+.sponsors-grid {
+ opacity: 0;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ flex-direction: column;
+}
+
+#home-sponsors-list {
+ flex-wrap: wrap;
+ width: 100%;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+}
+
+@media (max-width: 739px) {
+ .sponsors-grid {
+ justify-content: flex-start;
+ align-items: flex-start;
+ padding-top: 40px;
+ border-top: 1px solid rgba(255,255,255,.3);
+ }
+ #home-sponsors-list .sponsor-logo {
+ width: 33.33%;
+ padding: 10px;
+ }
+ #home-sponsors-list .sponsor-logo img {
+ max-width: 100%;
+ }
+}
diff --git a/documentation/assets/css/website.css b/documentation/assets/css/website.css
index be7e3fac..b938bc8b 100644
--- a/documentation/assets/css/website.css
+++ b/documentation/assets/css/website.css
@@ -108,7 +108,7 @@ a:hover .arrow:before,
/* Header */
.header {
- margin-top: 16px;
+ padding-top: 16px;
}
.nav-bar-content {
@@ -124,7 +124,12 @@ a:hover .arrow:before,
height: 48px;
}
+.header a {
+ opacity: .001;
+}
+
.nav-bar {
+ overflow: hidden;
display: flex;
justify-content: flex-end;
}
@@ -145,6 +150,8 @@ a.main-cta {
padding-left: 12px;
padding-right: 12px;
border-radius: 16px;
+ font-size: 16px;
+ font-weight: 600;
line-height: 2;
background-color: #F64E4D;
transition: transform .25s ease;
@@ -529,7 +536,6 @@ a.feature-icon:hover img {
bottom: 0;
display: flex;
align-items: center;
- /*justify-content: space-between;*/
width: 100%;
height: 100%;
}
@@ -920,17 +926,14 @@ a.feature-icon:hover img {
.sphere-animation {
position: absolute;
opacity: .001;
- top: 50%;
- left: 50%;
- width: 580px;
- height: 580px;
- margin: -290px 0 0 -290px;
+ top: 0%;
+ left: 0;
+ width: 100%;
+ height: 100%;
}
.sphere path {
- /*opacity: .001;*/
fill: rgba(37,36,35,.5);
- /*fill: linear-gradient(-180deg, #FFFFFF 0%, #F6F4F2 35%, #F6F4F2 69%, #DDDAD7 100%);*/
fill: url(#sphereGradient);
stroke-width: 1px;
stroke: #FF4847;
@@ -1058,4 +1061,4 @@ a.feature-icon:hover img {
.footer-text a {
font-size: 14px;
}
-}
\ No newline at end of file
+}
diff --git a/documentation/assets/img/sponsor-logo.png b/documentation/assets/img/sponsor-logo.png
new file mode 100644
index 00000000..d530198a
Binary files /dev/null and b/documentation/assets/img/sponsor-logo.png differ
diff --git a/documentation/assets/js/v4.js b/documentation/assets/js/v4.js
new file mode 100644
index 00000000..dc5f2b3a
--- /dev/null
+++ b/documentation/assets/js/v4.js
@@ -0,0 +1,16 @@
+// V4
+
+const $banner = document.querySelector('#top-banner');
+const $closeBanner = document.querySelector('#close-banner');
+
+function showBanner() {
+ document.body.classList.add('has-banner');
+}
+
+function closeBanner() {
+ document.body.classList.remove('has-banner');
+}
+
+setTimeout(showBanner, 2500);
+
+$closeBanner.onclick = closeBanner;
diff --git a/documentation/assets/js/website.js b/documentation/assets/js/website.js
index 35c28f9c..6332f4ff 100644
--- a/documentation/assets/js/website.js
+++ b/documentation/assets/js/website.js
@@ -1,4 +1,4 @@
-// import anime from '../../../lib/anime.es.js';
+// import anime from '../../../src/index.js';
/* Ontersection observer */
@@ -117,20 +117,30 @@ function isElementInViewport(el, inCB, outCB, rootMargin) {
observer.observe(el);
}
-function fitElementToParent(el, padding) {
- var timeout = null;
+function fitElementToParent(el, padding, exception) {
+ let windowWidth = 0;
+ let timeout = 0;
function resize() {
- if (timeout) clearTimeout(timeout);
anime.set(el, {scale: 1});
+ if (exception) anime.set(exception, {scale: 1});
var pad = padding || 0;
var parentEl = el.parentNode;
var elOffsetWidth = el.offsetWidth - pad;
var parentOffsetWidth = parentEl.offsetWidth;
var ratio = parentOffsetWidth / elOffsetWidth;
- timeout = setTimeout(anime.set(el, {scale: ratio}), 100);
+ var invertedRatio = elOffsetWidth / parentOffsetWidth;
+ anime.set(el, {scale: ratio});
+ if (exception) anime.set(exception, {scale: invertedRatio});
}
resize();
- window.addEventListener('resize', resize);
+ window.addEventListener('resize', function() {
+ if (window.innerWidth === windowWidth) return;
+ clearTimeout(timeout);
+ timeout = setTimeout(function() {
+ windowWidth = window.innerWidth;
+ resize();
+ }, 15);
+ });
}
// Update date and version number
@@ -153,7 +163,7 @@ var logoAnimation = (function() {
var logoAnimationEl = document.querySelector('.logo-animation');
var bouncePath = anime.path('.bounce path');
- fitElementToParent(logoAnimationEl, 0);
+ fitElementToParent(logoAnimationEl, 0, '.bounce svg');
anime.set(['.letter-a', '.letter-n', '.letter-i'], {translateX: 70});
anime.set('.letter-e', {translateX: -70});
@@ -279,7 +289,7 @@ var headerIntroAnimation = anime.timeline({
autoplay: false
})
.add({
- targets: ['.header a', '.secondary-menu a', '.section-intro .feature-description-text'],
+ targets: ['.header a', '.secondary-menu a', '.section-intro .feature-description-text', '.sponsors-grid'],
opacity: {value: [0.001, 1], easing: 'linear', duration: 300},
translateY: [40, 0],
translateZ: 0,
@@ -441,11 +451,9 @@ var sphereAnimation = (function() {
var sphereEl = document.querySelector('.sphere-animation');
var spherePathEls = sphereEl.querySelectorAll('.sphere path');
var pathLength = spherePathEls.length;
- var hasStarted = false;
+ var introPlayed = false;
var aimations = [];
- fitElementToParent(sphereEl);
-
var breathAnimation = anime({
begin: function() {
for (var i = 0; i < pathLength; i++) {
@@ -504,7 +512,10 @@ var sphereAnimation = (function() {
}, 0);
function play() {
- introAnimation.play();
+ if (!introPlayed) {
+ introAnimation.play();
+ introPlayed = true;
+ }
breathAnimation.play();
shadowAnimation.play();
}
@@ -563,7 +574,7 @@ var advancedStaggeringAnimation = (function() {
.add({
targets: '.stagger-visualizer .cursor',
keyframes: [
- { scale: .75, duration: 120},
+ { scale: .75, duration: 120},
{ scale: 2.5, duration: 220},
{ scale: 1.5, duration: 450},
],
@@ -688,7 +699,7 @@ var timeControlAnimation = (function() {
end: time.start,
easing: 'spring(.3, 200, 5, 1)',
update: function() { timelineAnimation.seek(time.end); },
- complete: function() {
+ complete: function() {
controlAnimationCanMove = true;
moveControlAnimation();
}
@@ -811,10 +822,10 @@ var layeredAnimation = (function() {
complete: function(anim) { animateShape(anim.animatables[0].target); },
})
.add({
- translateX: createKeyframes(function(el) {
+ translateX: createKeyframes(function(el) {
return el.classList.contains('large') ? anime.random(-300, 300) : anime.random(-520, 520);
}),
- translateY: createKeyframes(function(el) {
+ translateY: createKeyframes(function(el) {
return el.classList.contains('large') ? anime.random(-110, 110) : anime.random(-280, 280);
}),
rotate: createKeyframes(function() { return anime.random(-180, 180); }),
@@ -835,7 +846,7 @@ var layeredAnimation = (function() {
if (polyEl) {
animation.add({
targets: polyEl,
- points: createKeyframes(function() {
+ points: createKeyframes(function() {
var scale = anime.random(72, 180) / 100;
return trianglePoints.map(function(p) { return p * scale; }).join(' ');
}),
@@ -858,12 +869,12 @@ var layeredAnimation = (function() {
complete: function(anim) { animateProgress(anim.animatables[0].target); },
})
.add({
- transformOrigin: createKeyframes(function(el) {
+ transformOrigin: createKeyframes(function(el) {
return anime.random(0, 100) + '%';
})
}, 0)
.add({
- scaleX: createKeyframes(function(el) {
+ scaleX: createKeyframes(function(el) {
return anime.random(10, 100) / 100;
})
}, 0);
@@ -883,4 +894,4 @@ scrollToGettingStartedLink.addEventListener('click', function(e) {
scrollToElement(document.querySelector('#getting-started'));
})
-window.onload = introEasingsAnimation.init;
\ No newline at end of file
+window.onload = introEasingsAnimation.init;
diff --git a/documentation/index.html b/documentation/index.html
index 99e5233c..adf40ddf 100644
--- a/documentation/index.html
+++ b/documentation/index.html
@@ -25,12 +25,27 @@
<link href="assets/css/animejs.css" rel="stylesheet">
<link href="assets/css/anime-theme.css" rel="stylesheet">
<link href="assets/css/documentation.css" rel="stylesheet">
-
+ <link href="assets/css/v4.css" rel="stylesheet">
+ <!-- Google tag (gtag.js) -->
+ <script async src="https://www.googletagmanager.com/gtag/js?id=G-16LTPBS8QC"></script>
+ <script>
+ window.dataLayer = window.dataLayer || [];
+ function gtag(){dataLayer.push(arguments);}
+ gtag('js', new Date());
+ gtag('config', 'G-16LTPBS8QC');
+ </script>
<script src="../lib/anime.min.js"></script>
</head>
<body>
+ <div id="top-banner">
+ <button id="close-banner">✕</button>
+ <p>
+ Anime.js V4 is now in early access for GitHub Sponsors!
+ </p>
+ <a id="banner-cta" href="https://github.com/sponsors/juliangarnier" target="_blank">Try <span>Anime.js</span> V4</a>
+ </div>
<div class="content">
- <header class="header">
+ <header id="docs-header" class="header">
<a class="logo" href="https://github.com/juliangarnier/anime/">
<img class="anime-mini-logo" src="assets/img/anime-mini-logo.svg" />
<span class="version-number"></span>
@@ -2108,7 +2123,7 @@ anime({
<h3 class="demo-title">Axis</h3>
<div class="demo-description">
<p>
- Forces the direction of a <a href="#gridStaggering" class="color-staggering">grid starrering</a> effect.
+ Forces the direction of a <a href="gridStaggering" class="color-staggering">grid staggering</a> effect.
</p>
<pre><code>anime.stagger(value, {grid: [rows, columns], axis: 'x'})</code></pre>
<table>
@@ -2471,7 +2486,7 @@ tl
<h3 class="demo-title">Parameters inheritance</h3>
<div class="demo-description">
<p>
- Parameters set in the parent timeline instance will be inherited by all the children.
+ Some parameters set in the parent timeline instance can be inherited by all the children.
</p>
<table>
<thead>
@@ -2480,6 +2495,9 @@ tl
<tr>
<td><code>targets</code></td>
</tr>
+ <tr>
+ <td><code>easing</code></td>
+ </tr>
<tr>
<td><code>duration</code></td>
</tr>
@@ -2513,10 +2531,10 @@ tl
var tl = anime.timeline({
targets: '.params-inheritance-demo .el',
delay: function(el, i) { return i * 200 },
- duration: 500,
- easing: 'easeOutExpo',
- direction: 'alternate',
- loop: true
+ duration: 500, // Can be inherited
+ easing: 'easeOutExpo', // Can be inherited
+ direction: 'alternate', // Is not inherited
+ loop: true // Is not inherited
});
tl
@@ -4165,6 +4183,37 @@ anime({
</header>
<div class="info-output"></div>
</section>
+ <section class="pane sponsors-pane">
+ <header class="description-header">
+ <a target="_blank" href="https://github.com/sponsors/juliangarnier"><h2>Sponsors</h2></a>
+ </header>
+ <div id="docs-sponsors-list">
+ <a class="sponsor-logo" target="_blank" href="https://github.com/sponsors/juliangarnier">
+ <img src="assets/img/sponsor-logo.png" />
+ <span class="sponsor-name">Your logo here</span>
+ </a>
+ <a class="sponsor-logo" target="_blank" href="https://github.com/sponsors/juliangarnier">
+ <img src="assets/img/sponsor-logo.png" />
+ <span class="sponsor-name">Your logo here</span>
+ </a>
+ <a class="sponsor-logo" target="_blank" href="https://github.com/sponsors/juliangarnier">
+ <img src="assets/img/sponsor-logo.png" />
+ <span class="sponsor-name">Your logo here</span>
+ </a>
+ <a class="sponsor-logo" target="_blank" href="https://github.com/sponsors/juliangarnier">
+ <img src="assets/img/sponsor-logo.png" />
+ <span class="sponsor-name">Your logo here</span>
+ </a>
+ <a class="sponsor-logo" target="_blank" href="https://github.com/sponsors/juliangarnier">
+ <img src="assets/img/sponsor-logo.png" />
+ <span class="sponsor-name">Your logo here</span>
+ </a>
+ <a class="sponsor-logo" target="_blank" href="https://github.com/sponsors/juliangarnier">
+ <img src="assets/img/sponsor-logo.png" />
+ <span class="sponsor-name">Your logo here</span>
+ </a>
+ </div>
+ </section>
</div>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script>
@@ -4178,5 +4227,6 @@ anime({
<script src="assets/js/vendors/highlight.pack.js"></script>
<script src="assets/js/vendors/beautify-html.js"></script>
<script src="assets/js/documentation.js"></script>
+ <script src="assets/js/v4.js"></script>
</body>
</html>