tests and fitter cleanup
This commit is contained in:
parent
fc034092aa
commit
7794b7202f
@ -6,6 +6,7 @@ require 'compass/sass_extensions/sprites/image_helper'
|
||||
#classes
|
||||
require 'compass/sass_extensions/sprites/sprite_map'
|
||||
require 'compass/sass_extensions/sprites/image'
|
||||
require 'compass/sass_extensions/sprites/row_fitter'
|
||||
require 'compass/sass_extensions/sprites/image_row'
|
||||
require 'compass/sass_extensions/sprites/base'
|
||||
require 'compass/sass_extensions/sprites/engines'
|
||||
|
@ -4,7 +4,6 @@ module Compass
|
||||
module Processing
|
||||
def smart_packing
|
||||
fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(@images)
|
||||
|
||||
current_y = 0
|
||||
fitter.fit!.each do |row|
|
||||
current_x = 0
|
||||
@ -12,7 +11,6 @@ module Compass
|
||||
image.left = current_x
|
||||
image.top = current_y
|
||||
current_x += image.width
|
||||
image.left = image.position.unit_str == "%" ? (@width - image.width) * (image.position.value / 100) : image.position.value
|
||||
end
|
||||
current_y += row.height
|
||||
end
|
||||
|
@ -604,4 +604,37 @@ class SpritesTest < Test::Unit::TestCase
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should generate a sprite using smart packing" do
|
||||
css = render <<-SCSS
|
||||
$image_row-smart-pack: true;
|
||||
@import "image_row/*.png";
|
||||
@include all-image_row-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.image_row-sprite, .image_row-large, .image_row-large_square, .image_row-medium, .image_row-small, .image_row-tall {
|
||||
background: url('/image_row-7738758b32.png') no-repeat;
|
||||
}
|
||||
|
||||
.image_row-large {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.image_row-large_square {
|
||||
background-position: -100px -20px;
|
||||
}
|
||||
|
||||
.image_row-medium {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
|
||||
.image_row-small {
|
||||
background-position: -140px -20px;
|
||||
}
|
||||
|
||||
.image_row-tall {
|
||||
background-position: -160px -20px;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user