Rworked the animation. (v2)

Signed-off-by: Hermann Mayer's avatarHermann Mayer <hermann.mayer92@gmail.com>
parent 34a57d0e
# How to Contribute
The project follow the common
[Github](https://guides.github.com/activities/contributing-to-open-source/#contributing)/[Gitlab
contribution guidelines](http://doc.gitlab.com/ce/workflow/README.html).
Copyright 2017 Hermann Mayer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
File added
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./css/base.css">
<link rel="stylesheet" type="text/css" href="./css/transitions.css">
<link rel="stylesheet" type="text/css" href="./css/elements.css">
<script src="../node_modules/vivus/dist/vivus.js"></script>
<script src="./js/script.js"></script>
</head>
<body>
<div id="frame"></div>
</body>
</html>
@keyframes shaking {
25% {
transform: translate3d(4px, -20px, 0) rotate(-4.25deg);
}
50% {
transform: translate3d(0, 0, 0) rotate(0deg);
}
75% {
transform: translate3d(4px, -10px, 0) rotate(4.25deg);
}
100% {
transform: translate3d(0, 0, 0) rotate(0deg);
}
}
.shaking {
animation: shaking .4s ease infinite;
}
@keyframes scanning {
0% {
top: 0px;
stroke: #e74011;
}
50% {
top: 165px;
stroke: #2a6ab2;
}
100% {
top: 0px;
stroke: #e74011;
}
}
.scanning {
animation: scanning 1.5s linear infinite;
}
.scanning svg path {
animation: scanning 1.5s linear infinite;
}
body {
/* red e74011ff */
/* blue 2a6ab2ff */
background-color: #fff;
background-color: #000;
transition: all 0.5s ease;
overflow: hidden;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
#frame {
border: 1px solid #000;
position: absolute;
top: 167px;
left: 166px;
border: 1px solid #000;
background-color: #fff;
width: 749px;
height: 481px;
}
#belt, #ground, #ground-white, #ground-clouds {
position: absolute;
top: 365px;
left: 150px;
width: 800px;
margin: 0 auto;
z-index: 4;
opacity: 1;
}
#ground {
z-index: 5;
}
#ground-clouds {
z-index: 0;
}
#app, #app-rocket {
position: absolute;
top: 100px;
left: 100px;
width: 800px;
z-index: 1;
}
#app-rocket {
position: absolute;
top: 313px;
left: 173px;
width: 800px;
z-index: 1;
}
#checker-box {
position: absolute;
top: 267px;
left: 344px;
width: 400px;
z-index: -1;
}
#alarm {
position: absolute;
top: 113px;
left: 334px;
width: 400px;
z-index: -2;
}
#rocket-box {
position: absolute;
top: 188px;
left: 297px;
width: 400px;
z-index: 2;
}
#fire {
position: absolute;
top: 483px;
left: 524px;
width: 48px;
z-index: 0;
}
#fin {
position: absolute;
top: 252px;
left: 54px;
width: 900px;
z-index: 0;
}
@import url("elements/hausgold.css");
@import url("elements/app-generator.css");
@import url("elements/box.css");
@import url("elements/thing.css");
@import url("elements/belt.css");
@import url("elements/checker-box.css");
@import url("elements/rocket-box.css");
@import url("elements/ground.css");
@import url("elements/rocket.css");
@import url("elements/fin.css");
#app-generator {
position: absolute;
width: 400px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#belt {
position: absolute;
bottom: 10px;
left: 57px;
width: 646px;
z-index: 4;
opacity: 1;
}
#belt-wheel-left,
#belt-wheel-right {
position: absolute;
bottom: 13px;
left: 14px;
width: 85px;
margin: 0 auto;
z-index: 4;
opacity: 1;
}
#belt-wheel-right {
left: auto;
right: 14px;
}
#belt-wheel-left.rotate-left,
#belt-wheel-right.rotate-left {
transition: all .6s ease-in;
transform: rotate(-180deg);
}
#belt-wheel-left.rotate-left2,
#belt-wheel-right.rotate-left2 {
transition: all .6s ease-in;
transform: rotate(-360deg);
}
#belt-wheel-left.rotate-right,
#belt-wheel-right.rotate-right {
transition: all .6s ease-in;
transform: rotate(180deg);
}
#belt-wheel-left.rotate-right2,
#belt-wheel-right.rotate-right2 {
transition: all .6s ease-in;
transform: rotate(360deg);
}
#box {
position: absolute;
width: 140px;
z-index: 2;
top: 20px;
left: 100px;
}
#box.initial {
width: 400px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#box.down-scale {
transition: all .5s ease-in;
}
#box.falldown {
transition: all .5s ease-in;
top: 220px;
}
#box.move-middle {
transition: all .6s ease-in;
left: 298px;
}
#box.move-left {
transition: all .6s ease-in;
left: 98px;
}
#box.move-right {
transition: all .6s ease-in;
left: 522px;
}
#checker-box {
position: absolute;
bottom: 59px;
left: 267px;
width: 200px;
z-index: 2;
}
#checker-beam {
position: absolute;
top: 0px;
left: 2px;
width: 197px;
z-index: -1;
}
#checker-done {
position: absolute;
top: 0px;
left: 0px;
width: 200px;
z-index: 3;
}
#alarm {
position: absolute;
top: -48px;
left: 48px;
width: 97px;
z-index: -2;
}
#fin {
position: absolute;
width: 600px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#ground,
#ground-white {
position: absolute;
bottom: 6px;
left: 57px;
width: 646px;
z-index: 4;
}
#ground-white {
left: 0px;
top: 73px;
z-index: -1;
}
#ground-clouds {
position: absolute;
top: -52px;
left: 162px;
width: 327px;
z-index: 4;
}
#ground-clouds.grow-fade-out {
transition: all 3.8s linear;
position: absolute;
top: -128px;
left: 73px;
width: 525px;
opacity: 0 !important;
}
#hausgold {
position: absolute;
width: 400px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#rocket-box {
position: absolute;
bottom: 120px;
left: 175px;
width: 300px;
z-index: 2;
}
#rocket {
position: absolute;
width: 104px;
height: 180px;
z-index: 1;
top: 165px;
left: 161px;
transform: rotate(86deg);
offset-path: path('M 123.5539,347.47588 C 125.09866,321.33689 134.77468,218.04935 83.02299,155.58946 31.271294,93.129589 116.30005,33.853269 157.52081,79.105112 198.7416,124.35677 181.45671,204.27096 136.66151,220.15427 63.528519,246.08549 -21.113632,180.36465 38.324271,87.051409 84.139468,15.125043 207.7608,-118.38814 250.05057,-303.5124');
}
#fire {
position: absolute;
bottom: -20px;
left: 35px;
width: 34px;
z-index: -1;
}
#rocket-container {
width: 600px;
height: 600px;
transform: scale(.64);
transform-origin: 50% 0%;
position: absolute;
bottom: -93px;
left: 85px;
}
#rocket.fly-away {
animation: rocket-flyaway 3.2s linear infinite;
offset-distance: 0;
offset-rotate: auto;
}
#rocket.fly-away #fire {
animation: fire-flyaway 3.2s linear infinite;
offset-distance: 0;
offset-rotate: auto;
}
@keyframes rocket-flyaway {
0% {
width: 104px;
}
50% {
width: 65px;
}
100% {
offset-distance: 100%;
width: 35px;
}
}
@keyframes fire-flyaway {
0% {
width: 34px;
}
50% {
width: 25px;
bottom: 10px;
left: 20px;
}
100% {
offset-distance: 100%;
width: 25px;
bottom: 30px;
left: 5px;
}
}
.thing {
position: absolute;
width: 73px;
z-index: 1;
top: 0px;
left: 325px;
}
.thing.left {
left: 129px;
}
.thing.middle {
left: 325px;
}
.thing.right {
left: 550px;
}
.thing.falldown {
transition: all .5s ease-in;
top: 220px !important;
}
.coffee {
top: 0px;
margin-left: 10px;
width: 160px;
left: 270px;
}
.coffee.tip {
transition: all .5s ease-in;
transform: rotate(-180deg);
top: -4px;
}
#coffee-liquid {
top: -200px;
z-index: 0;
width: 50px;
left: 328px;
}
#coffee-liquid.falldown {
transition: all .5s ease-in;
top: 230px;
}
.falldown {
transition: all .5s ease-in;
top: 297px !important;
}
.move-middle {
transition: all .6s ease-in;
left: 298px !important;
}
.move-left {
transition: all .6s ease-in;
left: 98px !important;
}
.move-right {
transition: all .6s ease-in;
left: 498px !important;
}
.down-under {
transition: all 0.3s linear;
top: 800px !important;
}
.right-out {
transition: all 0.3s linear;
top: 800px !important;
transition: all .4s linear;
bottom: -335px !important;
}
.fade-out {
......@@ -34,28 +9,6 @@
}
.fade-out-slow {
transition: all 3.0s linear;
opacity: 0 !important;
}
.grow-fade-out {
transition: all 3.8s linear;
width: 1400px !important;
top: 260px !important;
left: -150px !important;
transition: all 3s linear;
opacity: 0 !important;
}
.fly-away-rocket {
transition: all 1s ease-in;
top: 112px !important;
width: 200px !important;
left: 446px !important;
}
.fly-away-fire {
transition: all 1.095s ease-in;
top: 112px !important;
width: 8px !important;
left: 534px !important;
}
<!DOCTYPE html>
<html>
<head>
<title>Animation</title>
<link rel="stylesheet" type="text/css" href="./css/base.css">
<link rel="stylesheet" type="text/css" href="./css/transitions.css">
<link rel="stylesheet" type="text/css" href="./css/animations.css">
<link rel="stylesheet" type="text/css" href="./css/elements.css">
<script src="../node_modules/vivus/dist/vivus.js"></script>
<script src="./js/commons.js"></script>
<script src="./js/durations.js"></script>
<script src="./js/lib.js"></script>
<script src="./js/box.js"></script>
<script src="./js/script.js"></script>
</head>
<body>
<div id="frame"></div>
<div id="frame">
<div id="rocket-container"></div>
</div>
</body>
</html>
if (!window.box) {
var box = window.box = {};
}
box.downScale = function() {
setClass('box', 'down-scale');
};
box.toBelt = function() {
setClass('box', 'falldown');
};
box.shake = function() {
delay(1)
.then(() => addClass('box', 'shaking'))
.then(() => delay(400))
.then(() => removeClass('box', 'shaking'));
};
box.rightToMiddle = function() {
setClass('box', 'falldown move-middle');
setClass('belt-wheel-left', 'rotate-left');
setClass('belt-wheel-right', 'rotate-left');
};
box.leftToMiddle = function() {
setClass('box', 'falldown move-middle');
setClass('belt-wheel-left', 'rotate-right');
setClass('belt-wheel-right', 'rotate-right');
};
box.middleToRight = function() {
setClass('box', 'falldown move-right');
setClass('belt-wheel-left', 'rotate-right2');
setClass('belt-wheel-right', 'rotate-right2');
};
box.middleToLeft = function() {
setClass('box', 'falldown move-left');
setClass('belt-wheel-left', 'rotate-left2');
setClass('belt-wheel-right', 'rotate-left2');
};
box.loadThing = function(thing, position) {
const classes = `thing ${position}`;
const opts = {
classes: classes,
basepath: 'things/'
};
return delay(1)
.then(() => svg(thing, 'delayed', opts))
.then(() => delay(1000))
.then(() => addClass(thing, 'falldown'))
.then(() => delay(550))
.then(() => box.shake())
.then(() => remove(thing));
};
box.loadCoffee = function() {
const classes = `coffee thing`;
const opts = {
classes: classes,
basepath: 'things/'
};
return delay(1)
.then(() => svg('coffee', 'delayed', opts))
.then(() => delay(1000))
.then(() => addClass('coffee', 'tip'))
.then(() => svg('coffee-liquid', 'delayed', opts))
.then(() => delay(150))
.then(() => addClass('coffee-liquid', 'falldown'))
.then(() => delay(550))
.then(() => addClass('coffee', 'falldown'))
.then(() => delay(550))
.then(() => box.shake())
.then(() => remove('coffee'))
.then(() => remove('coffee-liquid'));
};
function downUnder(id) {
addClass(id, 'down-under');
}
function fadeOut(id) {
addClass(id, 'fade-out');
}
function fadeOutSlow(id) {
addClass(id, 'fade-out-slow');
}
const durations = {
'hausgold' : 040 ,// 040
'app-generator' : 150 ,// 150
'box' : 130 ,// 130
'belt' : 060 ,// 060
'belt-wheel-left' : 060 ,// 060
'belt-wheel-right' : 060 ,// 060
'checker-box' : 030 ,// 030
'alarm' : 030 ,// 030
'rocket-box' : 010 ,// 010
'rocket' : 001 ,// 001
'ground' : 008 ,// 008
'ground-white' : 001 ,// 001
'fire' : 060 ,// 060
'ground-clouds' : 060 ,// 060
'fin' : 090 ,// 090
};
var elements = {};
const nodelay = false;
function delay(t) {
console.log(`sleep ${t}`);
return new Promise(function(resolve) {
if (nodelay) { resolve(); }
setTimeout(resolve, t)
});
}
function svg(id, type, opts) {