Skip to content

Instantly share code, notes, and snippets.

@rchipka
Created February 7, 2018 21:15
Show Gist options
  • Select an option

  • Save rchipka/081adf66e3b44b97b15cebf2090ba445 to your computer and use it in GitHub Desktop.

Select an option

Save rchipka/081adf66e3b44b97b15cebf2090ba445 to your computer and use it in GitHub Desktop.
SASS cubic bezier function for precalculated CSS easing
@function pow($number, $exponent) {
$value: 1;
@if $exponent > 0 {
@for $i from 1 through $exponent {
$value: $value * $number;
}
}
@return $value;
}
@function cubic-bezier($x, $a, $b, $c, $d) {
@return
($a * pow(1 - $x, 3)) +
($b * 3 * pow(1 - $x, 2) * $x) +
($c * 3 * (1 - $x) * pow($x, 2)) +
($d * pow($x, 3));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment