Skip to content

Commit 6cf62ef

Browse files
committed
animation cleanup
2 parents 244c779 + cdd4cee commit 6cf62ef

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

knapsack/_animations.scss

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Some animation defaults
2+
3+
$animation-duration: .65s;
4+
$animation-easing: ease-out;
5+
6+
// Mixin Animated
7+
//
8+
// Sets the main animation properties. Used in initialize-animation
9+
10+
@mixin animated() {
11+
animation-timing-function: $animation-easing;
12+
animation-duration: $animation-duration;
13+
animation-fill-mode: both;
14+
}
15+
16+
// Animation: Fade In
17+
//
18+
// Fades in element using opacity.
19+
@keyframes fade-in {
20+
0% { opacity: 0; }
21+
100% { opacity: 1;}
22+
}
23+
24+
@mixin fade-in() {
25+
animation-name: fade-in;
26+
}
27+
28+
// Animation: Fade In Up
29+
//
30+
// Fades in opacity and moves element up on the Y axis.
31+
32+
@keyframes fade-in-up {
33+
0% { opacity: 0; transform: translate3d(0, 15%, 0); }
34+
100% { opacity: 1; transform: none; }
35+
}
36+
37+
@mixin fade-in-up() {
38+
animation-name: fade-in-up;
39+
}
40+
41+
// Animation: Fade In Down
42+
//
43+
// Fades in opacity and moves element down on the Y axis.
44+
45+
@keyframes fade-in-down {
46+
0% { opacity: 0; transform: translate3d(0, -15%, 0); }
47+
100% { opacity: 1; transform: none; }
48+
}
49+
50+
@mixin fade-in-down {
51+
animation-name: fade-in-down;
52+
}
53+
54+
// Animation: Over-scale
55+
//
56+
// Creates an elastic scaling up bigger than 100% then resting to
57+
// 100% size.
58+
59+
@keyframes over-scale {
60+
0% { opacity: 0; transform: scale(0); }
61+
70% { transform: scale(1.1); }
62+
100% { opacity: 1; transform: scale(1); }
63+
}
64+
65+
@mixin over-scale() {
66+
animation-name: over-scale;
67+
}
68+
69+
// Additive Mixin: Initialize animation
70+
//
71+
// Warning: Creates classes in your css and styles them - not to be used inside
72+
// an element. Put this on your document root to get the animation goods.
73+
//
74+
// ex: @include initialize-animation(20);
75+
76+
@mixin initialize-animation($max-delay-classes: 20) {
77+
// Needed for every element that you want to animate
78+
.animated { @include animated(); }
79+
80+
// Individual animations
81+
.fade-in { @include fade-in(); }
82+
.fade-in-up { @include fade-in-up(); }
83+
.fade-in-down { @include fade-in-down(); }
84+
.over-scale { @include over-scale(); }
85+
86+
// Loop to create delay classes
87+
//
88+
// Creates .delay-1 .delay-2 .delay-3
89+
90+
@for $i from 1 through $max-delay-classes {
91+
$delay: $i * .1s;
92+
93+
.delay-#{$i} {
94+
animation-delay: $delay;
95+
}
96+
}
97+
}

knapsack/_index.scss

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Index
33
// ----
44

5+
@import 'animations';
56
@import 'code';
67
@import 'layout';
78
@import 'tables';

0 commit comments

Comments
 (0)