UNPKG

@skeleton-elements/vue

Version:

Skeleton elements (aka UI Skeletons, Skeleton Screens, Ghost Elements) are representations of UI that will be available (loaded) soon. They are designed to improve perceived performance.

21 lines (17 loc) 660 B
function multiplySvgPoints(pointsString, iconSize, width, height) { var iconMaxSize = Math.min(width, height) * 0.5; var scale = iconMaxSize / iconSize; // eslint-disable-next-line return pointsString.replace(/([0-9,\.]{1,})/g, function (coords) { // eslint-disable-next-line coords = coords.split(',').map(function (p) { return parseFloat(p); }); var x = coords[0] * scale + width / 2 - iconSize * scale / 2; var y = coords[1] * scale + height / 2 - iconSize * scale / 2; if (iconMaxSize >= 100) { return Math.round(x) + "," + Math.round(y); } return x + "," + y; }); } export default multiplySvgPoints;