(val: string, screenSize: number)
| 27 | } |
| 28 | |
| 29 | function getPixel(val: string, screenSize: number): number { |
| 30 | if (/^\d+px$/i.test(val)) { |
| 31 | return parseInt(val.replace(/px/i, '')); |
| 32 | } |
| 33 | if (/^\d+%$/i.test(val)) { |
| 34 | const proz = parseInt(val.replace(/%/i, '')); |
| 35 | return parseInt(`${screenSize * (proz / 100)}`); |
| 36 | } |
| 37 | return NaN; |
| 38 | } |