|
| 1 | +@import "shared"; |
| 2 | + |
| 3 | +// CSS Animations. |
| 4 | + |
| 5 | +// Apply an animation property and value with the correct browser support |
| 6 | +@mixin animation-support($property, $value) { |
| 7 | + @include experimental($property, $value, -moz, -webkit, -o, -ms, not -khtml, official); } |
| 8 | + |
| 9 | +// Name of any animation as a string. |
| 10 | +$default-animation-name : false !default; |
| 11 | + |
| 12 | +// Duration of the entire animation in seconds. |
| 13 | +$default-animation-duration : false !default; |
| 14 | + |
| 15 | +// Delay for start of animation in seconds. |
| 16 | +$default-animation-delay : false !default; |
| 17 | + |
| 18 | +// The timing function(s) to be used between keyframes. [ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier($number, $number, $number, $number)] |
| 19 | +$default-animation-timing-function : false !default; |
| 20 | + |
| 21 | +// The number of times an animation cycle is played. [infinite | $number] |
| 22 | +$default-animation-iteration-count : false !default; |
| 23 | + |
| 24 | +// Whether or not the animation should play in reverse on alternate cycles. [normal | alternate] |
| 25 | +$default-animation-direction : false !default; |
| 26 | + |
| 27 | +// What values are applied by the animation outside the time it is executing. [none | forwards | backwards | both] |
| 28 | +$default-animation-fill-mode : false !default; |
| 29 | + |
| 30 | +// Whether the animation is running or paused. [running | paused] |
| 31 | +$default-animation-play-state : false !default; |
| 32 | + |
| 33 | +// Create a named animation sequence that can be applied to elements later. |
| 34 | +// |
| 35 | +// $name - The name of your animation. |
| 36 | +// @content - The keyframes of the animation. |
| 37 | +@mixin keyframes( |
| 38 | + $name, |
| 39 | + $moz: $experimental-support-for-mozilla, |
| 40 | + $webkit: $experimental-support-for-webkit, |
| 41 | + $o: $experimental-support-for-opera, |
| 42 | + $ms: $experimental-support-for-microsoft, |
| 43 | + $khtml: $experimental-support-for-khtml, |
| 44 | + $official: true |
| 45 | +) { |
| 46 | + @if $moz { |
| 47 | + @include with-only-support-for($moz: true) { |
| 48 | + @-moz-keyframes #{$name} { @content; } |
| 49 | + } |
| 50 | + } |
| 51 | + @if $webkit { |
| 52 | + @include with-only-support-for($webkit: true) { |
| 53 | + @-webkit-keyframes #{$name} { @content; } |
| 54 | + } |
| 55 | + } |
| 56 | + @if $o { |
| 57 | + @include with-only-support-for($o: true) { |
| 58 | + @-o-keyframes #{$name} { @content; } |
| 59 | + } |
| 60 | + } |
| 61 | + @if $ms { |
| 62 | + @include with-only-support-for($ms: true) { |
| 63 | + @-ms-keyframes #{$name} { @content; } |
| 64 | + } |
| 65 | + } |
| 66 | + @if $khtml { |
| 67 | + @include with-only-support-for($khtml: true) { |
| 68 | + @-khtml-keyframes #{$name} { @content; } |
| 69 | + } |
| 70 | + } |
| 71 | + @if $official { |
| 72 | + @include with-only-support-for { |
| 73 | + @keyframes #{$name} { @content; } |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +// Apply 1-10 animation names. |
| 79 | +@mixin animation-name($name-1: $default-animation-name, $name-2: false, $name-3: false, $name-4: false, $name-5: false, $name-6: false, $name-7: false, $name-8: false, $name-9: false, $name-10: false) { |
| 80 | + $name: compact($name-1, $name-2, $name-3, $name-4, $name-5, $name-6, $name-7, $name-8, $name-9, $name-10); |
| 81 | + @include animation-support(animation-name, $name); } |
| 82 | + |
| 83 | +// Apply 1-10 animation durations. |
| 84 | +@mixin animation-duration($duration-1: $default-animation-duration, $duration-2: false, $duration-3: false, $duration-4: false, $duration-5: false, $duration-6: false, $duration-7: false, $duration-8: false, $duration-9: false, $duration-10: false) { |
| 85 | + $duration: compact($duration-1, $duration-2, $duration-3, $duration-4, $duration-5, $duration-6, $duration-7, $duration-8, $duration-9, $duration-10); |
| 86 | + @include animation-support(animation-duration, $duration); } |
| 87 | + |
| 88 | +// Apply 1-10 animation delays. |
| 89 | +@mixin animation-delay($delay-1: $default-animation-delay, $delay-2: false, $delay-3: false, $delay-4: false, $delay-5: false, $delay-6: false, $delay-7: false, $delay-8: false, $delay-9: false, $delay-10: false) { |
| 90 | + $delay: compact($delay-1, $delay-2, $delay-3, $delay-4, $delay-5, $delay-6, $delay-7, $delay-8, $delay-9, $delay-10); |
| 91 | + @include animation-support(animation-delay, $delay); } |
| 92 | + |
| 93 | +// Apply 1-10 animation timing functions. |
| 94 | +@mixin animation-timing-function($function-1: $default-animation-timing-function, $function-2: false, $function-3: false, $function-4: false, $function-5: false, $function-6: false, $function-7: false, $function-8: false, $function-9: false, $function-10: false) { |
| 95 | + $function: compact($function-1, $function-2, $function-3, $function-4, $function-5, $function-6, $function-7, $function-8, $function-9, $function-10); |
| 96 | + @include animation-support(animation-timing-function, $function); } |
| 97 | + |
| 98 | +// Apply 1-10 animation iteration counts. |
| 99 | +@mixin animation-iteration-count($count-1: $default-animation-iteration-count, $count-2: false, $count-3: false, $count-4: false, $count-5: false, $count-6: false, $count-7: false, $count-8: false, $count-9: false, $count-10: false) { |
| 100 | + $count: compact($count-1, $count-2, $count-3, $count-4, $count-5, $count-6, $count-7, $count-8, $count-9, $count-10); |
| 101 | + @include animation-support(animation-iteration-count, $count); } |
| 102 | + |
| 103 | +// Apply 1-10 animation directions. |
| 104 | +@mixin animation-direction($direction-1: $default-animation-direction, $direction-2: false, $direction-3: false, $direction-4: false, $direction-5: false, $direction-6: false, $direction-7: false, $direction-8: false, $direction-9: false, $direction-10: false) { |
| 105 | + $direction: compact($direction-1, $direction-2, $direction-3, $direction-4, $direction-5, $direction-6, $direction-7, $direction-8, $direction-9, $direction-10); |
| 106 | + @include animation-support(animation-direction, $direction); } |
| 107 | + |
| 108 | +// Apply 1-10 animation fill modes. |
| 109 | +@mixin animation-fill-mode($mode-1: $default-animation-fill-mode, $mode-2: false, $mode-3: false, $mode-4: false, $mode-5: false, $mode-6: false, $mode-7: false, $mode-8: false, $mode-9: false, $mode-10: false) { |
| 110 | + $mode: compact($mode-1, $mode-2, $mode-3, $mode-4, $mode-5, $mode-6, $mode-7, $mode-8, $mode-9, $mode-10); |
| 111 | + @include animation-support(animation-fill-mode, $mode); } |
| 112 | + |
| 113 | +// Apply 1-10 animation play states. |
| 114 | +@mixin animation-play-state($state-1: $default-animation-play-state, $state-2: false, $state-3: false, $state-4: false, $state-5: false, $state-6: false, $state-7: false, $state-8: false, $state-9: false, $state-10: false) { |
| 115 | + $state: compact($state-1, $state-2, $state-3, $state-4, $state-5, $state-6, $state-7, $state-8, $state-9, $state-10); |
| 116 | + @include animation-support(animation-play-state, $state); } |
| 117 | + |
| 118 | +// Shortcut to apply a named animation to an element, with all the settings. |
| 119 | +// |
| 120 | +// $animation-1 : Name and settings for the first animation. [<values> | default] |
| 121 | +// ... |
| 122 | +// $animation-10 : Name and settings for the tenth animation. <values> |
| 123 | +@mixin animation($animation-1: default, $animation-2: false, $animation-3: false, $animation-4: false, $animation-5: false, $animation-6: false, $animation-7: false, $animation-8: false, $animation-9: false, $animation-10: false) { |
| 124 | + @if $animation-1 == default { |
| 125 | + $animation-1: -compass-space-list(compact($default-animation-name, $default-animation-duration, $default-animation-timing-function, $default-animation-delay, $default-animation-iteration-count, $default-animation-direction, $default-animation-fill-mode, $default-animation-play-state)); } |
| 126 | + $animation: compact($animation-1, $animation-2, $animation-3, $animation-4, $animation-5, $animation-6, $animation-7, $animation-8, $animation-9, $animation-10); |
| 127 | + @include animation-support(animation, $animation); } |
0 commit comments