mapbox / spritezero

small opinionated sprites
Other
173 stars 62 forks source link

Adds stretchMetadata option to generateLayout functions #75

Closed jaericson closed 4 years ago

jaericson commented 4 years ago

Adds stretchMetadata as an optional option to generateLayout and generateLayoutUnique. If set to true, the resulting layout object will contain the following stretch metadata properties, if present: content, stretchX, and stretchY.

This leverages work from https://github.com/mapbox/spritezero/pull/68.

TODO:

jaericson commented 4 years ago

Whoops, looks like it's complaining about the spread operator usage. Maybe I need to revert back to using xtend?

jseppi commented 4 years ago

Whoops, looks like it's complaining about the spread operator usage.

Looks like eslint is what is having the problem. I think there's a way to fix that.

jseppi commented 4 years ago

Yeah, adding this to .eslintrc will do it:

    "parserOptions": {
        "ecmaVersion": 2018
    },

ref https://eslint.org/docs/user-guide/configuring#specifying-parser-options

jseppi commented 4 years ago

Is there any reason we should make the default instead be to include stretch metadata, if present?

👍 I'd be happy with it being enabled by default

jaericson commented 4 years ago

I'd be happy with it being enabled by default

@jseppi Great! Do you think we should rename the property to something like ignoreStretchMetadata so that omitting the property still means false?

jseppi commented 4 years ago

Do you think we should rename the property to something like ignoreStretchMetadata so that omitting the property still means false?

oof, that's a long name!

I don't actually have a strong preference, but I think you could also keep it as stretchMedata and defult to true by doing something like this:

options.stretchMedata = options.stretchMetadata !== undefined ? options.stretchMetadata : true