assetgraph-sprite
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -196,7 +196,32 @@ var _ = require('underscore'), | ||
incomingRelation.from.markDirty(); | ||
var relationSpriteInfo = AssetGraph.assets.Css.extractInfoFromRule(incomingRelation.cssRule, vendorPrefix + '-sprite-'); | ||
var relationSpriteInfo = AssetGraph.assets.Css.extractInfoFromRule(incomingRelation.cssRule, vendorPrefix + '-sprite-'), | ||
offsets = [ | ||
imageInfo.x, | ||
imageInfo.y | ||
]; | ||
if (incomingRelation.cssRule.style['background-position']) { | ||
// FIXME: Silently ignores other units than px | ||
var positions = incomingRelation.cssRule.style['background-position'].split(' ').map(function (item) { | ||
return parseInt(item, 10); | ||
}); | ||
if (positions.length !== 2 || isNaN(positions[0]) || isNaN(positions[1])) { | ||
console.warn( | ||
'WARNING: trying to sprite', | ||
imageInfo.asset.url, | ||
'with background-position:', | ||
incomingRelation.cssRule.style['background-position'] | ||
); | ||
} else { | ||
offsets[0] -= positions[0]; | ||
offsets[1] -= positions[1]; | ||
} | ||
} | ||
incomingRelation.cssRule.style.setProperty('background-position', | ||
(imageInfo.x ? (-imageInfo.x) + "px " : "0 ") + | ||
(imageInfo.y ? -imageInfo.y + "px" : "0"), | ||
relationSpriteInfo.important && 'important'); | ||
offsets.map(function (item) { | ||
return item ? -item + 'px' : '0'; | ||
}).join(' '), | ||
relationSpriteInfo.important && 'important'); | ||
['group', 'padding', 'no-group-selector', 'important'].forEach(function (propertyName) { | ||
@@ -203,0 +228,0 @@ incomingRelation.cssRule.style.removeProperty(vendorPrefix + '-sprite-' + propertyName); |
@@ -5,3 +5,3 @@ { | ||
"repository": "git://github.com/One-com/assetgraph-sprite.git", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"maintainers": [ | ||
@@ -26,3 +26,3 @@ { | ||
"assetgraph": "latest", | ||
"vows": ">=0.5.6" | ||
"vows": ">=0.6.2" | ||
}, | ||
@@ -29,0 +29,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34313
528