Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Improve demos

Julian Garnier09c6544431be
diff --git a/documentation/assets/js/fireworks.js b/documentation/assets/js/fireworks.js
index 5fbeaf26..24226e11 100644
--- a/documentation/assets/js/fireworks.js
+++ b/documentation/assets/js/fireworks.js
@@ -79,7 +79,7 @@ var fireworks = (function() {
for (var i = 0; i < numberOfParticules; i++) {
particules.push(createParticule(x, y));
}
- anime({
+ anime.timeline().add({
targets: particules,
x: function(p) { return p.endPos.x; },
y: function(p) { return p.endPos.y; },
@@ -87,8 +87,8 @@ var fireworks = (function() {
duration: anime.random(1200, 1800),
easing: 'easeOutExpo',
update: renderParticule
- });
- anime({
+ })
+ .add({
targets: circle,
radius: anime.random(128, 192),
lineWidth: 0,
@@ -99,13 +99,13 @@ var fireworks = (function() {
},
duration: anime.random(1200, 1800),
easing: 'easeOutExpo',
- update: renderParticule
+ update: renderParticule,
+ offset: 0
});
}
var render = anime({
duration: Infinity,
- autoplay: false,
update: function() {
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
}
@@ -113,8 +113,8 @@ var fireworks = (function() {
document.addEventListener(tap, function(e) {
window.human = true;
- updateCoords(e);
render.play();
+ updateCoords(e);
animateParticules(pointerX, pointerY);
ga('send', 'event', 'Fireworks', 'Click');
}, false);
diff --git a/documentation/assets/js/site.js b/documentation/assets/js/site.js
index 0f4f7dc0..a9c2b34c 100644
--- a/documentation/assets/js/site.js
+++ b/documentation/assets/js/site.js
@@ -183,11 +183,34 @@ var logoAnimation = (function() {
duration: 750,
offset: '-=1100'
})
+ .add({
+ targets: '.version',
+ innerHTML: parseFloat(anime.version, 10),
+ duration: 3000,
+ easing: 'easeInOutCubic',
+ update: function(a) {
+ var value = a.animatables[0].target.innerHTML;
+ value = parseFloat(value).toFixed(1);
+ a.animatables[0].target.innerHTML = value;
+ },
+ offset: '-=1000'
+ })
+ .add({
+ targets: '.date',
+ innerHTML: function() {
+ var d = new Date();
+ return d.getFullYear();
+ },
+ round: 1,
+ duration: 3000,
+ easing: 'easeInOutCubic',
+ offset: '-=3000'
+ })
function init() {
document.body.classList.add('ready');
- // logoTimeline.seek(2500);
+ // logoTimeline.seek(4700);
logoTimeline.play();
}
diff --git a/documentation/examples/anime-directions-testing.html b/documentation/examples/anime-directions-testing.html
index 9b2347b2..13adbc9c 100644
--- a/documentation/examples/anime-directions-testing.html
+++ b/documentation/examples/anime-directions-testing.html
@@ -29,14 +29,16 @@
padding: 1vw;
position: relative;
width: 33vw;
- height: 100px;
+ height: 20vh;
background: currentColor;
+ border: 1px solid #111116;
}
h2 {
color: #111116;
}
.el {
- margin-top: 1vw;
+ position: relative;
+ top: 5vh;
width: 2vw;
height: 2vw;
background: #111116;
@@ -48,10 +50,10 @@
align-items: center;
justify-content: center;
position: absolute;
- top: 1vw;
+ top: 1vh;
left: 0;
bottom: 0;
- height: 100%;
+ height: 19vh;
width: 100%;
}
input {
@@ -87,19 +89,23 @@
document.body.appendChild(testEl);
params.targets = testZoneEl.querySelectorAll('div');
- params.translateX = '26vw';
+ params.translateX = '29vw';
params.delay = 1000;
- params.begin = function() { testEl.classList.add('color-01') };
- params.update = function(a) { progressEl.value = a.progress + '%' };
- params.complete = function() { testEl.classList.add('color-04') };
+ params.begin = function() { testEl.classList.add('color-03') };
+ params.update = function(a) {
+ testEl.classList.add('color-01');
+ progressEl.value = a.progress + '%';
+ };
+ params.complete = function() { testEl.classList.add('color-05') };
var animation = anime(params);
animation.finished.then(function() {
promiseEl.value = 'Promise resolved'
console.log('Promise resolved');
});
testEl.onclick = function() {
- testEl.classList.remove('color-01');
- testEl.classList.remove('color-04');
+ testEl.classList.add('color-01');
+ testEl.classList.remove('color-03');
+ testEl.classList.remove('color-05');
animation.restart();
}
}
@@ -156,16 +162,16 @@
loop: 3
});
- createTest('Normal loop true', 1, {
+ createTest('Normal true', 1, {
loop: true
});
- createTest('Reverse loop true', 1, {
+ createTest('Reverse true', 1, {
direction: 'reverse',
loop: true
});
- createTest('Alternate loop true', 1, {
+ createTest('Alternate true', 1, {
direction: 'alternate',
loop: true
});
diff --git a/index.html b/index.html
index 04478cd8..30dca5ea 100644
--- a/index.html
+++ b/index.html
@@ -139,7 +139,7 @@
</a>
</div>
<p class="credits">
- © 2017 <a href="http://juliangarnier.com" target="_blank">Julian Garnier</a>
+ v<span class="version">0.0</span> © <span class="date">1986</span> <a href="http://juliangarnier.com" target="_blank">Julian Garnier</a>
</p>
</div>
<script>