UNPKG

@goongmaps/goong-map-react

Version:

A fork of react-map-gl. React components for Goong JS

13 lines (10 loc) 449 B
/* global window */ const pixelRatio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1; export const crispPixel = size => Math.round(size * pixelRatio) / pixelRatio; export const crispPercentage = (el, percentage, dimension = 'x') => { if (el === null) { return percentage; } const origSize = dimension === 'x' ? el.offsetWidth : el.offsetHeight; return (crispPixel((percentage / 100) * origSize) / origSize) * 100; };