nirsky / react-native-size-matters

A lightweight, zero-dependencies, React-Native utility belt for scaling the size of your apps UI across different sized devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dealing with negatives

mingyjongo opened this issue · comments

Hello there! I've just gotten started using ScaledSheet and it's awesome to have your functions available in shorthand like this, so kudos!

However! I almost immediately ran into errors in trying to scale a negative margin on an element. It appears your regex doesn't account for a dash in the beginning.

  • For scale():
const scaleRegex = /^(\d+(\.\d{1,2})?)@s$/
scaleRegex.test('-5@s') // false

add a couple characters........

const scaleRegex = /^(-?\d+(\.\d{1,2})?)@s$/
scaleRegex.test('-5@s') // true

and voilà!

Thanks @mingyjongo! Missed this one.
Fixed on PR #18.
Will be included in the next release.