Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Update demos

Julian Garnier363c4bc4053f
diff --git a/documentation/examples/anime-ease-visualizer.html b/documentation/examples/anime-ease-visualizer.html
index 7f172520..3c930bca 100644
--- a/documentation/examples/anime-ease-visualizer.html
+++ b/documentation/examples/anime-ease-visualizer.html
@@ -219,6 +219,7 @@
var pathEl = document.querySelector('.curve');
var presetsEls = document.querySelectorAll('.options button');
+ var ratio = window.innerWidth >= 980 ? 2 : 1;
var timeline = anime.timeline({
loop: true
@@ -239,7 +240,7 @@
{ value: [0, 1], delay: 0, duration: 500 },
{ value: 0, delay: 1500, duration: 500 }
],
- translateX: { value: [0, 400], delay: 500, duration: 1500 },
+ translateX: { value: [0, (200 * ratio)], delay: 500, duration: 1500 },
easing: 'linear',
offset: 0
}, {
@@ -248,7 +249,7 @@
{ value: [0, 1], delay: 0, duration: 500 },
{ value: 0, delay: 1500, duration: 500 }
],
- translateY: { value: [0, -400], delay: 500, duration: 1500, easing: easingName },
+ translateY: { value: [0, -(200 * ratio)], delay: 500, duration: 1500, easing: easingName },
easing: 'linear',
offset: 0
}, {
diff --git a/documentation/examples/anime-logo-animation.html b/documentation/examples/anime-logo-animation.html
index 963b76b5..b1a881da 100644
--- a/documentation/examples/anime-logo-animation.html
+++ b/documentation/examples/anime-logo-animation.html
@@ -196,128 +196,147 @@
</div>
<script>
- var logoTimeline = anime.timeline({
- loop: true,
- direction: 'alternate',
- autoplay: false
- });
+ var logoAnimation = (function() {
- logoTimeline
- .add({
- targets: '.dot-e',
- translateX: [
- { value: -600, duration: 520, delay: 200, easing: 'easeInQuart' },
- { value: [-100, 0], duration: 500, delay: 1000, easing: 'easeOutQuart' }
- ],
- scale: [
- { value: [0, 1], duration: 200, easing: 'easeOutBack' },
- { value: 0, duration: 20, delay: 500, easing: 'easeInQuart' },
- { value: 1, duration: 200, delay: 1000, easing: 'easeOutQuart' },
- { value: 0, duration: 400, delay: 500, easing: 'easeInBack' }
- ],
- offset: 0
- })
- .add({
- targets: '.dot-i',
- translateY: { value: [-200, 0], duration: 500, elasticity: 400 },
- scale: [
- { value: [0, 1], duration: 100, easing: 'easeOutQuart' },
- { value: 0, duration: 400, delay: 1400, easing: 'easeInBack' }
- ],
- delay: 1200,
- offset: 0
- })
- .add({
- targets: '.fill.in',
- strokeDashoffset: {
- value: [anime.setDashoffset, 0],
- duration: 600,
- delay: function(el, i, t) { return 700 + ( i * 100 ); },
- easing: 'easeOutQuart'
- },
- stroke: {
- value: ['#FFF', function(el) { return anime.getValue(el.parentNode, 'stroke') } ],
- duration: 500,
- delay: 500,
- easing: 'easeInQuad'
- },
- opacity: {
- value: 0,
- duration: 1,
- delay: function(el, i, t) { return 1900 + ( i * 80 ); },
- },
- offset: 0
- })
- .add({
- targets: '.fill.out',
- strokeDashoffset: [
- { value: [anime.setDashoffset, anime.setDashoffset], duration: 1890 },
- {
- value: [0, anime.setDashoffset],
- duration: 800,
- delay: function(el, i) { return (i * 80); },
- easing: 'easeInQuart'
- }
- ],
- offset: 0
- })
- .add({
- targets: '.line.out',
- strokeDashoffset: {
- value: [0, anime.setDashoffset],
- duration: 1200,
- delay: function(el, i, t) { return 2500 + ( i * 100 ); },
- easing: 'easeInQuart'
- },
- strokeWidth: {
- value: [0, 2],
- delay: function(el, i, t) { return 2000 + ( i * 100 ); },
- duration: 200,
- easing: 'linear'
- },
- offset: 0
- })
- .add({
- targets: '.icon',
- opacity: { value: 1, duration: 10, delay: 2800, easing: 'linear' },
- translateY: { value: 60, duration: 800 },
- delay: 4200,
- offset: 0
- })
- .add({
- targets: '.icon-line',
- strokeDashoffset: [
- { value: [anime.setDashoffset, anime.setDashoffset], duration: 3000 },
- { value: 0, duration: 1200, easing: 'easeInOutQuart' }
- ],
- strokeWidth: {
- value: [8, 2],
- delay: 3000,
- duration: 800,
- easing: 'easeInQuad'
- },
- stroke: {
- value: ['#FFF', function(el) { return anime.getValue(el, 'stroke') } ],
- duration: 800,
- delay: 3400,
- easing: 'easeInQuad'
- },
- offset: 0
- })
- .add({
- targets: ['.icon-text path', '.icon-text polygon'],
- translateY: [50, 0],
- opacity: { value: [0, 1], duration: 100, easing: 'linear' },
- delay: function(el, i, t) { return 4200 + ( i * 20 ); },
- offset: 0
- })
+ var logoEl = document.querySelector('.logo-animation');
+ var pathEls = document.querySelectorAll('.logo-animation path:not(.icon-curve)');
+ var innerWidth = window.innerWidth;
+ var maxWidth = 740;
+ var logoScale = innerWidth <= maxWidth ? innerWidth / maxWidth : 1;
+ var logoTimeline = anime.timeline({ autoplay: false, direction: 'alternate', loop: true });
- function init() {
- document.body.classList.add('ready');
- logoTimeline.play();
- }
+ logoEl.style.transform = 'translateY(50px) scale('+logoScale+')';
+
+ for (var i = 0; i < pathEls.length; i++) {
+ var el = pathEls[i];
+ el.setAttribute('stroke-dashoffset', anime.setDashoffset(el));
+ }
+
+ logoTimeline
+ .add({
+ targets: '.dot-e',
+ translateX: [
+ { value: -600, duration: 520, delay: 200, easing: 'easeInQuart' },
+ { value: [-100, 0], duration: 500, delay: 1000, easing: 'easeOutQuart' }
+ ],
+ scale: [
+ { value: [0, 1], duration: 200, easing: 'easeOutBack' },
+ { value: 0, duration: 20, delay: 500, easing: 'easeInQuart' },
+ { value: 1, duration: 200, delay: 1000, easing: 'easeOutQuart' },
+ { value: 0, duration: 400, delay: 500, easing: 'easeInBack' }
+ ],
+ offset: 0
+ })
+ .add({
+ targets: '.dot-i',
+ translateY: { value: [-200, 0], duration: 500, elasticity: 400 },
+ scale: [
+ { value: [0, 1], duration: 100, easing: 'easeOutQuart' },
+ { value: 0, duration: 400, delay: 1400, easing: 'easeInBack' }
+ ],
+ delay: 1200,
+ offset: 0
+ })
+ .add({
+ targets: '.fill.in',
+ strokeDashoffset: {
+ value: [anime.setDashoffset, 0],
+ duration: 600,
+ delay: function(el, i, t) { return 700 + ( i * 100 ); },
+ easing: 'easeOutQuart'
+ },
+ stroke: {
+ value: ['#FFF', function(el) { return anime.getValue(el.parentNode, 'stroke') } ],
+ duration: 500,
+ delay: 500,
+ easing: 'easeInQuad'
+ },
+ opacity: {
+ value: 0,
+ duration: 1,
+ delay: function(el, i, t) { return 1900 + ( i * 80 ); },
+ },
+ offset: 0
+ })
+ .add({
+ targets: '.fill.out',
+ strokeDashoffset: [
+ { value: [anime.setDashoffset, anime.setDashoffset], duration: 1890 },
+ {
+ value: [0, anime.setDashoffset],
+ duration: 800,
+ delay: function(el, i) { return (i * 80); },
+ easing: 'easeInQuart'
+ }
+ ],
+ offset: 0
+ })
+ .add({
+ targets: '.line.out',
+ strokeDashoffset: {
+ value: [0, anime.setDashoffset],
+ duration: 1200,
+ delay: function(el, i, t) { return 2500 + ( i * 100 ); },
+ easing: 'easeInQuart'
+ },
+ strokeWidth: {
+ value: [0, 2],
+ delay: function(el, i, t) { return 2000 + ( i * 100 ); },
+ duration: 200,
+ easing: 'linear'
+ },
+ offset: 0
+ })
+ .add({
+ targets: '.icon',
+ opacity: { value: 1, duration: 10, delay: 2800, easing: 'linear' },
+ translateY: { value: 60, duration: 800 },
+ delay: 4200,
+ offset: 0
+ })
+ .add({
+ targets: '.icon-line',
+ strokeDashoffset: [
+ { value: [anime.setDashoffset, anime.setDashoffset], duration: 3000 },
+ { value: 0, duration: 1200, easing: 'easeInOutQuart' }
+ ],
+ strokeWidth: {
+ value: [8, 2],
+ delay: 3000,
+ duration: 800,
+ easing: 'easeInQuad'
+ },
+ stroke: {
+ value: ['#FFF', function(el) { return anime.getValue(el, 'stroke') } ],
+ duration: 800,
+ delay: 3400,
+ easing: 'easeInQuad'
+ },
+ offset: 0
+ })
+ .add({
+ targets: ['.icon-text path', '.icon-text polygon'],
+ translateY: [50, 0],
+ opacity: { value: [0, 1], duration: 100, easing: 'linear' },
+ delay: function(el, i, t) { return 4200 + ( i * 20 ); },
+ offset: 0
+ })
+
+ function init() {
+ document.body.classList.add('ready');
+ // logoTimeline.seek(4700);
+ logoTimeline.play();
+ }
- window.onload = init;
+ return {
+ init: init
+ }
+
+ })();
+
+ window.onload = function() {
+ logoAnimation.init();
+ }
</script>
<script src="../assets/js/stats.js"></script>