put in the row fitter
This commit is contained in:
parent
cc26b98909
commit
370044ba77
@ -7,7 +7,7 @@ GIT
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
compass (0.11.1.d9ca08f)
|
||||
compass (0.11.1.cc26b98)
|
||||
chunky_png (~> 1.1)
|
||||
fssm (>= 0.2.7)
|
||||
sass (~> 3.1)
|
||||
|
@ -71,16 +71,10 @@ module Compass
|
||||
# collects image sizes and input parameters for each sprite
|
||||
def compute_image_positions!
|
||||
imgs = @images.sort { |a,b| a.width <=> b.width }
|
||||
rows = [::Compass::SassExtensions::Sprites::ImageRow.new(@width)]
|
||||
imgs.each do |image|
|
||||
next if rows.last.add(image)
|
||||
|
||||
rows << ::Compass::SassExtensions::Sprites::ImageRow.new(@width)
|
||||
unless rows.last.add(image)
|
||||
raise "Image failed to be added"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(imgs)
|
||||
rows = fitter.fit!
|
||||
|
||||
current_y = 0
|
||||
rows.each do |row|
|
||||
current_x = 0
|
||||
|
@ -1,18 +0,0 @@
|
||||
module Compass
|
||||
module SassExtensions
|
||||
module Sprites
|
||||
class ImageGroup
|
||||
attr_reader :images
|
||||
|
||||
def initialize(images = [])
|
||||
@images = images
|
||||
end
|
||||
|
||||
def best_fitting_rows
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -8,6 +8,7 @@ module Compass
|
||||
|
||||
attr_reader :images, :rows
|
||||
def_delegators :rows, :[]
|
||||
|
||||
def initialize(images)
|
||||
@images = images
|
||||
@rows = []
|
||||
@ -15,6 +16,7 @@ module Compass
|
||||
|
||||
def fit!(style = :scan)
|
||||
send("#{style}_fit")
|
||||
@rows
|
||||
end
|
||||
|
||||
def width
|
||||
|
@ -1,9 +0,0 @@
|
||||
require 'test_helper'
|
||||
require 'compass/sass_extensions/sprites/image_group'
|
||||
|
||||
class ImageGroupTest < Test::Unit::TestCase
|
||||
def setup
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user