Skip to content

Consider spacing on smart layout. Improves #1303 Fixes #718 #1429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/compass/sass_extensions/sprites/layout/smart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,29 @@ def layout!
def calculate_positions!
fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(@images)
current_y = 0
width = 0
height = 0
last_row_spacing = 9999
fitter.fit!.each do |row|
current_x = 0
current_x = 0
row_height = 0
row.images.each_with_index do |image, index|
extra_y = [image.spacing - last_row_spacing,0].max
if index > 0
last_image = row.images[index-1]
current_x += [image.spacing, last_image.spacing].max
end
image.left = current_x
image.top = current_y
image.top = current_y + extra_y
current_x += image.width
width = [width, current_x].max
row_height = [row_height, extra_y + image.height + image.spacing].max
end
current_y += row.height
height = [height, current_y].max
last_row_spacing = row_height - row.height
current_y += last_row_spacing
end
@width = fitter.width
@height = fitter.height
Expand Down