Socialify

Folder ..

Viewing _pm-loader-animation.scss
79 lines (68 loc) • 1.7 KB

 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
// Init values
$animation-duration       : 3s !default;
$second-circle-time-offset: .125s !default;

// We need to adjust animation for each size.
$stroke-map: (
	default: 4.5,
	bold   : 6.5,
	xbold : 15
) !default;

.loadingAnimation {
	// We need a different duration than each circle for the whole loader
	// to have an animation that seems visually "random", so here, duration +20% and ease.
	animation: loaderRotation #{$animation-duration * 1.2} ease-in-out infinite;
	will-change: transform;

	@keyframes loaderRotation {
		from { transform: rotate(0); }
		to   { transform: rotate(360deg); }
	}

	&-circle {
		transform-origin: 50%;
		fill: none;
		stroke: currentColor;
		stroke-width: map-get($stroke-map, default);
		will-change: transform;
		animation: $animation-duration linear infinite;

		&:nth-of-type(1) {
			animation-name: loaderOrbitX;
		}

		&:nth-of-type(2) {
			animation-name: loaderOrbitY;
			animation-delay: $second-circle-time-offset;
		}
	}

	@each $name, $value in $stroke-map {

		@if $name != 'default' {
			&.is-#{$name} &-circle {
				stroke-width: $value;

				&:nth-of-type(1) {
					animation-name: #{'loaderOrbitX-' + $name};
				}

				&:nth-of-type(2) {
					animation-name: #{'loaderOrbitY-' + $name};
				}
			}
		}

		@each $axis in (X,Y) {
			@keyframes #{'loaderOrbit' + $axis + if($name == 'default', '', '-' + $name)} {
				from {
					transform: #{'rotate' + $axis + '(0)'};
					stroke-width: $value;
				}
				25% {
					stroke-width: $value * 2;
				}
				50% {
					stroke-width: $value;
				}
				75% {
					stroke-width: $value * 2;
				}
				to {
					transform: #{'rotate' + $axis + '(360deg)'};
					stroke-width: $value;
				}
			}
		}
	}
}