Skip to content

Commit bf56596

Browse files
committed
let potpack do the sorting
1 parent 60f9996 commit bf56596

13 files changed

+3897
-3906
lines changed

lib/generate.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ module.exports.generateLayout = generateLayout;
99
module.exports.generateLayoutUnique = generateLayoutUnique;
1010
module.exports.generateImage = generateImage;
1111

12-
13-
function heightAscThanNameComparator(a, b) {
14-
return (b.height - a.height) || ((a.id === b.id) ? 0 : (a.id < b.id ? -1 : 1));
15-
}
16-
17-
1812
/**
1913
* Pack a list of images with width and height into a sprite layout.
2014
* options object with the following keys:
@@ -171,11 +165,8 @@ function generateLayoutInternal(options, callback) {
171165
// remove nulls that get introduced if removeOversizedIcons is true
172166
imagesWithSizes = imagesWithSizes.filter((img) => img);
173167

174-
// TODO: is this sort needed?
175-
imagesWithSizes.sort(heightAscThanNameComparator);
176-
177168
// TODO: do we need to do anything with other ShelfPack args?
178-
// potpack mutates the argument
169+
// potpack mutates the given array
179170
const sprite = potpack(imagesWithSizes);
180171

181172
if (options.format) {

0 commit comments

Comments
 (0)