All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.compass-1.0.3.lib.compass.sass_extensions.sprites.layout.smart.rb Maven / Gradle / Ivy

There is a newer version: 3.7.2
Show newest version
module Compass
  module SassExtensions
    module Sprites
      module Layout
        class Smart < SpriteLayout

          def layout!
            calculate_positions!
          end

        private # ===========================================================================================>

          def calculate_positions!
            fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(@images)
            current_y = 0
            fitter.fit!.each do |row|
              current_x = 0
              row.images.each_with_index do |image, index|
                image.left = current_x
                image.top = current_y
                current_x += image.width
              end
              current_y += row.height
            end
            @width = fitter.width
            @height = fitter.height
          end

        end
      end
    end
  end
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy