added default spacing
This commit is contained in:
parent
bf47c74dc2
commit
c62b8e718d
@ -4,11 +4,12 @@ module Compass::SassExtensions::Functions::Sprites
|
||||
path, name = Compass::Sprites.path_and_name(uri)
|
||||
y = 0
|
||||
last_spacing = 0
|
||||
default_spacing = number_from_var("#{name}-spacing")
|
||||
images = Compass::Sprites.sprites(name)
|
||||
images.each do |image|
|
||||
current_spacing = number_from_var("#{name}-#{image[:name]}-spacing")
|
||||
if y > 0
|
||||
y += current_spacing > last_spacing ? current_spacing : last_spacing
|
||||
y += [current_spacing, last_spacing, default_spacing].max
|
||||
end
|
||||
image[:y] = y
|
||||
y += image[:height]
|
||||
|
@ -197,4 +197,25 @@ describe Compass::Sprites do
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should calculate the default spacing between images" do
|
||||
css = render <<-SCSS
|
||||
$squares-spacing: 22px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
css.should == <<-CSS
|
||||
.squares-sprite, .squares-10x10, .squares-20x20 {
|
||||
background: url('/squares.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-10x10 {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-20x20 {
|
||||
background-position: 0 -32px;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user