UNPKG

@globalfishingwatch/react-map-gl

Version:

A React wrapper for MapboxGL-js and overlay API.

11 lines (10 loc) 461 B
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; }; //# sourceMappingURL=crisp-pixel.js.map