-
Notifications
You must be signed in to change notification settings - Fork 64
/
_animations.less
135 lines (113 loc) · 3.9 KB
/
_animations.less
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Variables
// --------------------------------------------------
@duration: 0.2s;
@progress-duration: 0.5s;
@animation-delay: 1s;
@animation-duration: 2000ms;
@animation-easing: cubic-bezier(.23,1,.32,1);
// Basic image zoom on hover animation
// Apply to image container
//
// .img-zoom();
// .img-zoom(@duration: .5s;);
// .img-zoom(1.25; .1s; ease-out;);
// --------------------------------------------------
.img-zoom(@scale: 1.1; @duration: .75s; @easing: ease-in-out;) {
overflow: hidden;
img {
transition: transform @duration @easing;
.no-touch &:hover {
transform: scale(@scale);
}
}
}
// --------------------------------------------------
// _onScreen Animations
// --------------------------------------------------
// Add an overflow to the animation container to stop horizontal scrolling
// on smaller devices
// https://github.com/adaptlearning/adapt_framework/issues/2675
// --------------------------------------------------
.has-animation {
overflow: hidden;
}
// Fade in
// --------------------------------------------------
.fade-in-before > div {
opacity: 0;
transition: all @animation-duration @animation-easing, visibility 0s linear 0s;
}
.fade-in-after > div {
opacity: 1;
}
// _onScreen animation mixin for 'fade-in-top', 'fade-in-bottom',
// 'fade-in-left', and 'fade-in-right'
// --------------------------------------------------
.on-screen-anim(fade-in-top; 0; 1; @animation-delay; translateY(-100px); translateY(0));
.on-screen-anim(fade-in-bottom; 0; 1; @animation-delay; translateY(100px); translateY(0));
.on-screen-anim(fade-in-left; 0; 1; @animation-delay; translateX(-100px); translateX(0));
.on-screen-anim(fade-in-right; 0; 1; @animation-delay; translateX(100px); translateX(0));
.on-screen-anim(@selector; @opacity-before; @opacity-after; @transition-delay; @transform-before; @transform-after) {
.@{selector}-before > div {
opacity: @opacity-before;
transform: @transform-before;
transition: all @animation-duration @animation-easing, visibility 0s linear 0s;
transition-delay: @transition-delay;
}
.@{selector}-after > div {
opacity: @opacity-after;
transform: @transform-after;
}
}
// --------------------------------------------------
// Keyframe Animations
// --------------------------------------------------
.keyframes(@name; @args) {
@keyframes @name { @args(); }
}
.animation(@args) {
animation: @args;
}
// scalePulse animation
// --------------------------------------------------
.effect-scalePulse() {
.keyframes(scalePulse; {
0% { transform: none; }
50% { transform: scale( 1.2, 1.2 ); }
100% { transform: none; }
});
.animation(scalePulse 0.5s 0s 1 normal ease-in-out none);
// name, duration, delay, iteration count, direction, timing-function, fill mode
}
// bounceLeftOnce animation
// --------------------------------------------------
.effect-bounceLeftOnce() {
.keyframes(bounceLeftOnce; {
0% { transform: translateX(0); }
50% { transform: translateX(-5px); }
100% { transform: translateX(0); }
});
.animation(bounceLeftOnce 0.5s 0s 1 normal ease-in-out none);
// name, duration, delay, iteration count, direction, timing-function, fill mode
}
// bounceRightOnce animation
// --------------------------------------------------
.effect-bounceRightOnce() {
.keyframes(bounceRightOnce; {
0% { transform: translateX(0); }
50% { transform: translateX(5px); }
100% { transform: translateX(0); }
});
.animation(bounceRightOnce 0.5s 0s 1 normal ease-in-out none);
// name, duration, delay, iteration count, direction, timing-function, fill mode
}
// 360 spin animation
// --------------------------------------------------
.effect-spin() {
.keyframes(spin; {
0% { transform: rotateZ(0); }
100% { transform: rotateZ(360deg); }
});
.animation(spin 1s 0s infinite normal ease-in-out none);
// name, duration, delay, iteration count, direction, timing-function, fill mode
}