twolfson / gulp.spritesmith

Convert a set of images into a spritesheet and CSS variables via gulp
The Unlicense
1.08k stars 81 forks source link

Padding on retina sprite images #69

Closed petulla closed 9 years ago

petulla commented 9 years ago

hi

I'm finding that the padding setting isn't working for retina sprites. Any advice?

twolfson commented 9 years ago

Can you provide an example?

petulla commented 9 years ago

Sure,

on the page, if I set padding on the sprite, I see:

screen shot 2015-09-28 at 6 25 23 pm

This is odd. The sprite itself has padding:

screen shot 2015-09-28 at 6 25 30 pm

How do I reconcile what I'm seeing on the page (a sprite with extra padding) vs. the sprite itself?

twolfson commented 9 years ago

Can you paste the gulp.src and configuration you are using?

petulla commented 9 years ago
 var spriteData =
    gulp.src(config.paths.src.assets + '/sprites/*.*') //
            .pipe(spritesmith({
              retinaSrcFilter: [config.paths.src.assets + '/sprites/*@2x.png'],
                padding:5,
                imgName: 'sprite.png',
                retinaImgName: 'sprite@2x.png',
                cssName: '_sprite.scss',
                cssFormat: 'scss_retina',
                algorithm: 'binary-tree'
            }));
    spriteData.img.pipe(gulp.dest(config.paths.build.style)); //
    spriteData.css.pipe(gulp.dest(config.paths.src.style + '/sass')); //
petulla commented 9 years ago

I find the on the page vs. the sprite behavior odd.. thoughts?

twolfson commented 9 years ago

Everything looks like it should work. From the fragmented screenshots of the spritesheets, it looks like the sprites were loaded out of order though. Any idea why that would be?

petulla commented 9 years ago

It appears as though the background is repeating..I.e., the padding doesn't extend to the edges.

twolfson commented 9 years ago

We only pad between sprites -- the edge padding wouldn't make sense as it's built to remove bleeding due to browser scaling (Ensighten/spritesmith#7)

https://github.com/Ensighten/spritesmith/blob/1.4.0/src/smith.js#L77-L82

https://github.com/Ensighten/spritesmith/blob/1.4.0/src/smith.js#L120-L126

petulla commented 9 years ago

I needed to add the padding manually to the retina mixin to solve the problem. I also needed to prevent background-repeat to eliminate the duplication issue.

twolfson commented 9 years ago

Not sure what you mean by that since we double padding for retina spritesheets =/

https://github.com/twolfson/gulp.spritesmith/blob/4.1.1/lib/gulp-spritesmith.js#L188

But in any case, I am glad your issue is resolved =)