diff --git a/app/assets/javascripts/branch-graph.js.coffee b/app/assets/javascripts/branch-graph.js.coffee
index f6d57bd55bba7394eb2c612e5767a858b2526b23..349924f0d01d1eb949fc04ab898ec5443931b857 100644
--- a/app/assets/javascripts/branch-graph.js.coffee
+++ b/app/assets/javascripts/branch-graph.js.coffee
@@ -90,11 +90,15 @@ class BranchGraph
 
   renderPartialGraph: ->
     start = Math.floor((@element.scrollTop() - @offsetY) / @unitTime) - 10
-    start = 0 if start < 0
+    if start < 0
+      isGraphEdge = true
+      start = 0
     end = start + 40
-    end = @commits.length if @commits.length < end
+    if @commits.length < end
+      isGraphEdge = true
+      end = @commits.length
 
-    if @prev_start == -1 or Math.abs(@prev_start - start) > 10
+    if @prev_start == -1 or Math.abs(@prev_start - start) > 10 or isGraphEdge
       i = start
 
       @prev_start = start