Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Update demos

Julian Garnierd74c780631b7
diff --git a/documentation/assets/css/site.css b/documentation/assets/css/site.css
index 8f28e24d..918d3f9e 100644
--- a/documentation/assets/css/site.css
+++ b/documentation/assets/css/site.css
@@ -203,6 +203,11 @@ body.ready { opacity: 1; }
transform: rotate(180deg);
}
+.button path {
+ scale: .9;
+ transform-origin: 50% 50%;
+}
+
.credits {
opacity: 0;
margin-top: 20px;
@@ -210,10 +215,35 @@ body.ready { opacity: 1; }
}
.credits a {
+ position: relative;
color: currentColor;
text-decoration: none;
}
-.credits a:hover {
- text-decoration: underline;
+.credits a:after {
+ content: "";
+ opacity: 0;
+ display: block;
+ position: absolute;
+ left: 0;
+ bottom: -3px;
+ width: 100%;
+ border-bottom: 1px solid currentColor;
+ transition: opacity .75s ease;
+}
+
+/*.credits a:hover:after {
+ opacity: 1;
+ transition: opacity .25s ease;
+}*/
+
+.credits a,
+.credits span {
+ transition: color .75s ease;
+}
+
+.credits a:hover,
+.highlighted {
+ color: white;
+ transition: color .25s ease;
}
\ No newline at end of file
diff --git a/documentation/assets/js/fireworks.js b/documentation/assets/js/fireworks.js
index 0ba7943d..5ba00f3d 100644
--- a/documentation/assets/js/fireworks.js
+++ b/documentation/assets/js/fireworks.js
@@ -2,7 +2,7 @@ var fireworks = (function() {
var canvasEl = document.querySelector('.fireworks');
var ctx = canvasEl.getContext('2d');
- var numberOfParticules = 32;
+ var numberOfParticules = Number(location.href.split('?')[1]) || 40;
var pointerX = 0;
var pointerY = 0;
var tap = ('ontouchstart' in window || navigator.msMaxTouchPoints) ? 'touchstart' : 'mousedown';
diff --git a/documentation/assets/js/site.js b/documentation/assets/js/site.js
index a9c2b34c..8c41c94f 100644
--- a/documentation/assets/js/site.js
+++ b/documentation/assets/js/site.js
@@ -2,33 +2,39 @@ var createBouncyButtons = (function() {
function createButton(el) {
var pathEl = el.querySelector('path');
var spanEl = el.querySelector('span');
- pathEl.setAttribute('stroke-dashoffset', anime.setDashoffset(pathEl));
- var animation = anime.timeline({
- autoplay: false
- });
- animation
- .add({
- targets: pathEl,
- d: 'M10,10 C10,10 50,7 90,7 C130,7 170,10 170,10 C170,10 172,20 172,30 C172,40 170,50 170,50 C170,50 130,53 90,53 C50,53 10,50 10,50 C10,50 8,40 8,30 C8,20 10,10 10,10 Z',
- duration: 150,
- easing: 'easeInOutSine',
- offset: 0
- })
- .add({
- targets: spanEl,
- scale: 1.1,
- duration: 150,
- easing: 'easeInOutSine',
- offset: 0
- })
- el.onmouseenter = function() {
- if (animation.reversed) animation.reverse();
- animation.play();
+ function hover() {
+ anime.remove([pathEl, spanEl]);
+ anime({
+ targets: pathEl,
+ d: 'M10,10 C10,10 50,7 90,7 C130,7 170,10 170,10 C170,10 172,20 172,30 C172,40 170,50 170,50 C170,50 130,53 90,53 C50,53 10,50 10,50 C10,50 8,40 8,30 C8,20 10,10 10,10 Z',
+ elasticity: 700,
+ offset: 0
+ });
+ anime({
+ targets: spanEl,
+ scale: 1.2,
+ duration: 800,
+ offset: 0
+ });
}
- el.onmouseleave = function() {
- if (!animation.reversed) animation.reverse();
- animation.play();
+ function down() {
+ anime.remove([pathEl, spanEl]);
+ anime({
+ targets: pathEl,
+ d: 'M10,10 C10,10 50,9.98999977 90,9.98999977 C130,9.98999977 170,10 170,10 C170,10 170.009995,20 170.009995,30 C170.009995,40 170,50 170,50 C170,50 130,50.0099983 90,50.0099983 C50,50.0099983 10,50 10,50 C10,50 9.98999977,40 9.98999977,30 C9.98999977,20 10,10 10,10 Z',
+ elasticity: 700,
+ offset: 0
+ });
+ anime({
+ targets: spanEl,
+ scale: 1,
+ duration: 800,
+ offset: 0
+ });
}
+ el.onmouseenter = hover;
+ el.onmousedown = down;
+ el.onmouseleave = down;
}
var buttonEls = document.querySelectorAll('.button');
@@ -176,23 +182,18 @@ var logoAnimation = (function() {
},
offset: '-=250'
})
- .add({
- targets: '.button path',
- strokeDashoffset: [anime.setDashoffset, 0],
- easing: 'easeInOutQuart',
- duration: 750,
- offset: '-=1100'
- })
.add({
targets: '.version',
innerHTML: parseFloat(anime.version, 10),
- duration: 3000,
- easing: 'easeInOutCubic',
+ duration: 2500,
+ easing: 'easeOutCubic',
+ begin: function(a) { a.animatables[0].target.classList.add('highlighted'); },
update: function(a) {
var value = a.animatables[0].target.innerHTML;
value = parseFloat(value).toFixed(1);
a.animatables[0].target.innerHTML = value;
},
+ complete: function(a) { a.animatables[0].target.classList.remove('highlighted'); },
offset: '-=1000'
})
.add({
@@ -202,9 +203,11 @@ var logoAnimation = (function() {
return d.getFullYear();
},
round: 1,
- duration: 3000,
- easing: 'easeInOutCubic',
- offset: '-=3000'
+ duration: 2500,
+ easing: 'easeOutCubic',
+ begin: function(a) { a.animatables[0].target.classList.add('highlighted'); },
+ complete: function(a) { a.animatables[0].target.classList.remove('highlighted'); },
+ offset: '-=2500'
})
diff --git a/documentation/examples/anime-DOM-stress-test.html b/documentation/examples/anime-DOM-stress-test.html
index 2fd685d6..ba28d3f9 100644
--- a/documentation/examples/anime-DOM-stress-test.html
+++ b/documentation/examples/anime-DOM-stress-test.html
@@ -37,7 +37,7 @@
<body></body>
<script>
- var maxElements = 400;
+ var maxElements = Number(location.href.split('?')[1]) || 300;
var duration = 1500;
var toAnimate = [];
var radius = window.innerWidth < window.innerHeight ? window.innerWidth : window.innerHeight;
diff --git a/documentation/index.html b/documentation/index.html
index 706402b2..932539e2 100644
--- a/documentation/index.html
+++ b/documentation/index.html
@@ -19,7 +19,7 @@
<link href="assets/css/anime.css" rel="stylesheet">
<link href="assets/css/anime-theme.css" rel="stylesheet">
<link href="assets/css/documentation.css" rel="stylesheet">
- <script src="../anime.min.js"></script>
+ <script src="../anime.js"></script>
</head>
<body>
<div class="content">
diff --git a/index.html b/index.html
index b6817841..2acc2b49 100644
--- a/index.html
+++ b/index.html
@@ -129,13 +129,13 @@
<svg viewBox="0 0 180 60">
<path d="M10,10 C10,10 50,9.98999977 90,9.98999977 C130,9.98999977 170,10 170,10 C170,10 170.009995,20 170.009995,30 C170.009995,40 170,50 170,50 C170,50 130,50.0099983 90,50.0099983 C50,50.0099983 10,50 10,50 C10,50 9.98999977,40 9.98999977,30 C9.98999977,20 10,10 10,10 Z"></path>
</svg>
- <span>Examples</span>
+ <span>CodePen</span>
</a>
<a class="button green" href="https://github.com/juliangarnier/anime" target="_blank">
<svg viewBox="0 0 180 60">
<path d="M10,10 C10,10 50,9.98999977 90,9.98999977 C130,9.98999977 170,10 170,10 C170,10 170.009995,20 170.009995,30 C170.009995,40 170,50 170,50 C170,50 130,50.0099983 90,50.0099983 C50,50.0099983 10,50 10,50 C10,50 9.98999977,40 9.98999977,30 C9.98999977,20 10,10 10,10 Z"></path>
</svg>
- <span>Documentation</span>
+ <span>GitHub</span>
</a>
</div>
<p class="credits">