Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprite image order bug? for Retina image #125

Closed
nakagaw opened this issue May 25, 2017 · 2 comments
Closed

Sprite image order bug? for Retina image #125

nakagaw opened this issue May 25, 2017 · 2 comments
Labels

Comments

@nakagaw
Copy link

nakagaw commented May 25, 2017

Thank you for produced this plugin. so helpful for me.

I had used Retina supports on gulp.spritesmith, Sprite image order problem happen.

At first, I ready these images,

I had adding all Retina parameters to gulp.js, and start generated,
But, Sprite order became to reverse with none-retina and retina sprites image.

Generated images order each positon are:
None retina sprites => sprite
Retina sprites => sprite 2x

But, I replaced file name from "@2x" to "-2x", It was not happen problem.

If you think this is bug, Could you please try, Thanks.

@twolfson
Copy link
Owner

This is a known issue but there's not much we can do. The cause is us using sort() and JavaScript gives different priority to 2 over @ where it doesn't exist in the normal version:

> var normal = ['cat.png', 'cat2.png'];
undefined
> normal.sort();
[ 'cat.png', 'cat2.png' ]
> var retina = ['cat@2x.png', 'cat2@2x.png'];
undefined
> retina.sort();
[ 'cat2@2x.png', 'cat@2x.png' ]

This is better explained in twolfson/grunt-spritesmith#137

To resolve the issue, we suggest using consistent suffixes between files (e.g. cat1.png, cat2.png). Switching delimiters might work for this scenario but it can break again if there are files like house.png and house-blue.png.

@nakagaw
Copy link
Author

nakagaw commented May 25, 2017

I got it. Thanks your reply! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants