Created
May 19, 2016 15:27
-
-
Save ColeTownsend/827109c1714c03d50d27dcbea0b6a948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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