Skip to content

Commit

Permalink
Fix uncaught exception when navigating collapsed trees too fast
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Aug 4, 2015
1 parent b89581a commit db91437
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,29 @@ function setCurrentTreePosition(tree, index) {
// Set current path
var t = tree
while (t.parent) {
t.parent.collapsed = false
t.parent.current = t.parent.subtrees.indexOf(t)
t = t.parent
}

// Update graph and slider
if (tree.collapsed && index == tree.nodes.length - 1) {
tree.collapsed = false
updateGraph()
}
setTimeout(function() {
if (!new Tuple(tree, index).equals(getCurrentTreePosition())) return

var n = getCurrentGraphNode()
var expanded = false || tree.collapsed && index == tree.nodes.length - 1
var t = tree

setTimeout(function() {
if (n && getCurrentGraphNode() == n)
centerGraphCameraAt(n)
while (t.parent && t.parent.collapsed) {
expanded = true
t.parent.collapsed = false
t = t.parent
}

if (expanded) {
tree.collapsed = false
updateGraph()
}

centerGraphCameraAt(getCurrentGraphNode())
updateSlider()
}, setting.get('graph.delay'))

Expand Down Expand Up @@ -301,7 +308,7 @@ function prepareSlider() {
function prepareDragDropFiles() {
Element.NativeEvents.dragover = 2
Element.NativeEvents.drop = 2

document.body.addEvent('dragover', function() {
return false
}).addEvent('drop', function(e) {
Expand Down

0 comments on commit db91437

Please sign in to comment.