chriseppstein/compass — pull request #866 by kwliou (2012-04-28 07:14:25+00:00)
Title: add a sprite-image-position() helper function

This is would be really useful for for automatic sprite handling. I use Compass spriting in many group projects and often other people don't want to deal with advanced spriting.

I don't insert elements just for icons so for an icon that's supposed to be on the very right side of a block element, I would normally do something like:

$map-sprite-position: 100%;
...
.map-sprite {
@include sprite-background-position($map-sprites, sprite, 100%);
}
Using this helper method, I can then write something like:

@mixin adjust-sprite-positions($map) {
@each $sprite in sprite-names($map) {
$position: sprite-image-position($map, $sprite);
@if $position != 0 and unit($position) == "%" {
.#{sprite-map-name($map)-$sprite} {
@include sprite-background-position($map, $sprite, $position);
}
}
}
}