Skip to content

Instantly share code, notes, and snippets.

@albb0920
Last active January 21, 2019 11:44
Show Gist options
  • Save albb0920/262fffdbb2c52cb4d08b2e87aeded97b to your computer and use it in GitHub Desktop.
Save albb0920/262fffdbb2c52cb4d08b2e87aeded97b to your computer and use it in GitHub Desktop.
@function linear-calc($min, $max, $depend-expr, $depend-min, $depend-max) {
$range: $max - $min;
$grow-rate: $range / ($depend-max - $depend-min);
@return calc(
#{$min} + (#{$depend-expr} - #{$depend-min}) * #{$grow-rate}
);
}
$min-header-height: 40px;
$max-header-height: 80px;
@at-root :root {
// js onScroll 變更
--header-height: #{$max-header-height};
}
@function depend-on-header-height($min, $max) {
@return linear-calc(
$min: $min,
$max: $max,
$depend-expr: var(--header-height),
$depend-min: $min-header-height,
$depend-max: $max-header-height
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment