madlittlemods / gulp-css-spriter Goto Github PK
View Code? Open in Web Editor NEWSprite Sheet Generation from CSS source files. The best and different approach to sprite sheets.
Home Page: https://www.npmjs.com/package/gulp-css-spriter
Sprite Sheet Generation from CSS source files. The best and different approach to sprite sheets.
Home Page: https://www.npmjs.com/package/gulp-css-spriter
Hi, I use this gulp plugin generate sprite sheet. But the image in keyframes (I use css3 animation).The css not change, like below:
@keyframes good-morning {
0% {
background-image: url("../../images/animation/a1.png");
}
14.28571429% {
background-image: url("../../images/animation/a2.png");
}
28.57142857% {
background-image: url("../../images/animation/a3.png");
}
42.85714286% {
background-image: url("../../images/animation/a4.png");
}
57.14285714% {
background-image: url("../../images/animation/a5.png");
}
71.42857143% {
background-image: url("../../images/animation/a6.png");
}
85.71428571% {
background-image: url("../../images/animation/a7.png");
}
100% {
background-image: url("../../images/animation/a1.png");
}
}
so, i fork the source code and add rule.type with keyframes map-over-styles-and-transform-background-image-declarations.js. The code is below:
if(rule.type === 'keyframes') {
// Get keyframe from keyframes
rule.keyframes = transformMap(rule.keyframes, function(keyframe, keyframeIndex, keyframes) {
// Get declarations from keyframe
keyframe.declarations = transformMap(keyframe.declarations, function(declaration, declarationIndex, declarations) {
// Clone the declartion to keep it immutable
var transformedDeclaration = extend(true, {}, declaration);
transformedDeclaration = attachInfoToDeclaration(declarations, declarationIndex);
// background-image always has a url
if(transformedDeclaration.property === 'background-image') {
return cb(transformedDeclaration, declarationIndex, declarations);
}
// Background is a shorthand property so make sure `url()` is in there
else if(transformedDeclaration.property === 'background') {
var hasImageValue = spriterUtil.backgroundURLRegex.test(transformedDeclaration.value);
if(hasImageValue) {
return cb(transformedDeclaration, declarationIndex, declarations);
}
}
// Wrap in an object so that the declaration doesn't get interpreted
return {
'value': transformedDeclaration
};
});
});
}
Now, the css will be:
@keyframes good-morning {
0% {
background-image: url("../../images/spritesheet.png");
background-position: -0px -0px;
}
14.28571429% {
background-image: url("../../images/spritesheet.png");
background-position: -180px -0px;
}
28.57142857% {
background-image: url("../../images/spritesheet.png");
background-position: -360px -0px;
}
42.85714286% {
background-image: url("../../images/spritesheet.png");
background-position: -540px -0px;
}
57.14285714% {
background-image: url("../../images/spritesheet.png");
background-position: -0px -300px;
}
71.42857143% {
background-image: url("../../images/spritesheet.png");
background-position: -180px -300px;
}
85.71428571% {
background-image: url("../../images/spritesheet.png");
background-position: -360px -300px;
}
100% {
background-image: url("../../images/spritesheet.png");
background-position: -0px -0px;
}
}
Hope to merge or fix this bug.
When you have minified/compressed CSS or have multiple background image declarations on a single line. The whole declarations get messed up.
This is caused by not having a column offset when you find/replace the first declaration.
Add gulp-sourcemaps
support.
hello~ uh, I try this plugin to make a spriter pic. but, gulp throw an error message: error creating sprite sheet image :unsupported interlace method. finally( about 2 hours later hahahah),I import some png with AI instead of PS. This plugin runs successful. So er... my question is :Is PS‘s image algorithm make gulp-css-spriter throw such error message?
Add support for the @media
at-rule.
When I add a background-image
declaration into a media query, it doesn't get picked up and sprited.
Add an option to conditionally filter images based on the image URL
For example, any image with ?__spriter
will be sprited
background-image: url('./images/test.png?__spriter');
The example will produce a image,spritesheet.png
, that will have two instances of aenean-purple.png
.
This seems to be a bug introduced in v0.3.0.
gulp.task('sprite', function() {
// './test-css/minimal-for-bare-testing.css'
return gulp.src(['./test1.css', './test2.css'])
.pipe(spriter({
'includeMode': 'implicit',
'spriteSheet': './spritesheet.png',
}));
});
.aenean
{
width: 120px;
height: 100px;
background: url('../test-images/aenean-purple.png');
}
.aenean2
{
width: 120px;
height: 100px;
background: url('../test-images/aenean-purple.png');
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.