code: function calculatePercentInShadow(minReferenceCoord, maxReferenceCoord, minPotentialCoord, maxPotentialCoord) {
              /// Calculates the percentage of the potential element that is in the shadow of the reference element.
              if ((minReferenceCoord >= maxPotentialCoord) || (maxReferenceCoord <= minPotentialCoord)) {
                  // Potential is not in the reference's shadow.
                  return 0;
              }
              var pixelOverlap = Math.min(maxReferenceCoord, maxPotentialCoord) - Math.max(minReferenceCoord, minPotentialCoord);
              var shortEdge = Math.min(maxPotentialCoord - minPotentialCoord, maxReferenceCoord - minReferenceCoord);
              return shortEdge === 0 ? 0 : (pixelOverlap / shortEdge);
          }
docs: Nested Helpers