Skip to content

Instantly share code, notes, and snippets.

@ColeTownsend
Created May 19, 2016 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ColeTownsend/827109c1714c03d50d27dcbea0b6a948 to your computer and use it in GitHub Desktop.
Save ColeTownsend/827109c1714c03d50d27dcbea0b6a948 to your computer and use it in GitHub Desktop.
var setWidthOfRow = function(item, index) {
var selector = `#miles-${index}`;
var width;
var itemDistance = item.distance;
var amountOfActivities = activities.length;
if (amountOfActivities < 7) {
activityNormalizer = (7 - amountOfActivities) / 2
} else {
activityNormalizer = 1;
}
if (totalDistance === 0) {
width = maxWidth / runs.length;
$(selector).addClass("no-miles");
} else if (itemDistance === 0 ) {
var fakeDist = totalDistance / runs.length;
width = roundToSingleDecimal((fakeDist / runs.length), 1) * maxWidth / activityNormalizer;
$(selector).addClass("no-miles");
} else {
width = roundToSingleDecimal((itemDistance / totalDistance), 1) * maxWidth / activityNormalizer;
}
$(selector).css("width", `${width}px`);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment