Skip to content

Commit

Permalink
Merge pull request #2040 from DerGenaue/patch-1
Browse files Browse the repository at this point in the history
Fix secondsToZoom to work correctly for exact matches
  • Loading branch information
DylanC authored Aug 30, 2018
2 parents 407a111 + d600d16 commit 962978a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/classes/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ def zoomToSeconds(zoomValue):

def secondsToZoom(scaleValue):
""" Convert a number of seconds to a timeline zoom factor """
if scaleValue in zoomSeconds:
return zoomSeconds[scaleValue]
else:
# Find closest zoom
closestValue = zoomSeconds[0]
for zoomValue in zoomSeconds:
if zoomValue < scaleValue:
closestValue = zoomValue
return zoomSeconds.index(closestValue)
# Find closest zoom or exact match
closestValue = zoomSeconds[0]
for zoomValue in zoomSeconds:
if zoomValue > scaleValue:
break;
closestValue = zoomValue
return zoomSeconds.index(closestValue)

0 comments on commit 962978a

Please sign in to comment.