gems.compass-1.0.3.lib.compass.sass_extensions.sprites.layout.diagonal.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sass-maven-plugin Show documentation
Show all versions of sass-maven-plugin Show documentation
A Maven Plugin that compiles Sass files.
module Compass
module SassExtensions
module Sprites
module Layout
class Diagonal < SpriteLayout
def layout!
calculate_width!
calculate_height!
calculate_positions!
end
private # ===========================================================================================>
def calculate_width!
@width = @images.inject(0) {|sum, img| sum + img.width}
end
def calculate_height!
@height = @images.inject(0) {|sum, img| sum + img.height}
end
def calculate_positions!
previous = nil
@images.each_with_index do |image, index|
if previous.nil?
previous = image
image.top = @height - image.height
image.left = 0
next
end
image.top = previous.top - image.height
image.left = previous.left + previous.width
previous = image
end
end
end
end
end
end
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy