Skip to content

Commit

Permalink
fixed bug where negative scales broke when base is a list and one ite…
Browse files Browse the repository at this point in the history
…m in base is 1(em or px)
  • Loading branch information
codingdesigner committed Jul 5, 2012
1 parent 032ebe4 commit 2c23acf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
8 changes: 4 additions & 4 deletions stylesheets/_modular-scale.sass
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ $class-slug: ms !default
$i: $i - 1
@if $multiple < 0
// do the scale down for each set to below 1px
$i: -1
$i: 0
$modular-scale: nth($base-size, $k)
@while $modular-scale > 1
@while $i >= $multiple
$modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
$scale-values: append($scale-values, $modular-scale)
$i: $i - 1
Expand Down Expand Up @@ -144,9 +144,9 @@ $class-slug: ms !default
$i: $i - 1
@if $multiple < 0
// do the scale down for each set to below 1px
$i: -1
$i: 0
$modular-scale: nth($base-size, $k)
@while $modular-scale > 1
@while $i >= $multiple
$modular-scale: power($ratio, $i) * nth($base-size, $k)
$scale-values: append($scale-values, $modular-scale)
$i: $i - 1
Expand Down
2 changes: 1 addition & 1 deletion test/public/stylesheets/example.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ h3 {
}

.baz {
font-size: 13px;
font-size: 11px;
}

.ms-0 {
Expand Down
24 changes: 6 additions & 18 deletions test/sass/example.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
// path to local mixin
@import "../../stylesheets/modular-scale";

$base-size: 16px 44px;
$ratio: $golden $major-third;

// @debug deg-to-rad(127deg);
// @debug deg-to-rad(127);
// @debug sort(6 5 7 4 8 3 9 2 0 10 1);
// @debug reverse(sort(6 5 7 4 8 3 9 2 0 10 1));
// @debug modular-scale-list();
@debug modular-scale(-3);
@debug modular-scale(-2);
@debug modular-scale(-1);
@debug modular-scale(0);
@debug modular-scale(1);
@debug modular-scale(2);
@debug modular-scale(3);
// @debug modular-scale(4);
// @debug modular-scale(5);
// @debug modular-scale(100);
// $base-size: 1px 16px;
// $base-size: 1em 16em;
// $base-size: 1em;
// $ratio: $golden $major-third;
// @debug modular-scale-list(-15, 30);
// @debug modular-scale(-10);

// Defining the background color so we can see what is going on.
html {
Expand Down

0 comments on commit 2c23acf

Please sign in to comment.