Skip to content

Commit a694400

Browse files
committed
Remove the collapse animation for the package list's initial appearance.
For large datasets, the initialization time was through the roof (90+ seconds for a package list with around 1500 items in it). I think the problem was that the PackageWidgets were going through animations while also trying to measure things (slideUp/Down to collapse/expand all at once, and trying to measure the width of the barchart bars for label positioning). I added an 'animate' parameter to the 'collapseChildren' method, and use false for the initial collapse of all of the widgets. I also removed the 'animating' property, since nothing was using it, and it looked relatively expensive to calculate. Now the 90 second load time is more like 5 seconds (for the dataset I was testing with, Jenkins)
1 parent c984d06 commit a694400

File tree

2 files changed

+11
-45
lines changed

2 files changed

+11
-45
lines changed

codepulse/src/main/resources/toserve/pages/traces/PackageController.js

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
// build this into a Map[packageId -> packageWidget.selectedProp]
2727
var stateTemplate = {}
2828

29-
// build this into a Map[packageId -> packageWidget.collapsingProp]
30-
var collapsingTemplate = {}
31-
3229
var widgets = {}
3330

3431
// initialize the `stateTemplate` and `widgets` maps
@@ -39,17 +36,15 @@
3936
var pw = new PackageWidget()
4037
widgets[node.id] = pw
4138

39+
pw.collapseChildren(/* collapsed = */true, /* animate = */false)
40+
4241
stateTemplate[node.id] = pw.selectedProp
4342
pw.selectionClicks.onValue(function(){
4443
handleSelectionClick(node, pw)
4544
})
4645

47-
collapsingTemplate[node.id] = pw.collapsingProp
48-
49-
// pw.selectedProp.log('selected ' + node.id)
50-
5146
pw.uiParts.collapser.click(function(event){
52-
pw.collapseChildren('toggle')
47+
pw.collapseChildren('toggle', true)
5348
event.stopPropagation()
5449
})
5550

@@ -153,29 +148,6 @@
153148
}
154149
})
155150

156-
/**
157-
* Pushes a `1` event when the package widgets' collapse/expand
158-
* animation finishes. Used to update affix things since the
159-
* animation affects the page height.
160-
*/
161-
this.widgetsAnimating = Bacon
162-
.combineTemplate(collapsingTemplate)
163-
.map(function(o){
164-
for(var k in o) if(o[k]) return true
165-
return false
166-
})
167-
.skipDuplicates()
168-
.toProperty(false)
169-
.slidingWindow(2)
170-
.filter(function(a){
171-
// accepted as the 'animating' prop goes from true to false
172-
if(a.length == 2 && a[0] === true && a[1] === false) return true
173-
return false
174-
})
175-
.map(function(){ return 1 })
176-
177-
for(k in widgets) widgets[k].collapseChildren(true)
178-
179151
/**
180152
* Getter / Setter for "compact" mode, which causes the
181153
* widgets to take on a compact look.
@@ -220,7 +192,7 @@
220192
function recurse(node){
221193
var count = 0
222194

223-
if(node.kind == 'method') count += 1
195+
if(node.kind == 'method') ++count
224196

225197
;(node.children || []).forEach(function(kid){
226198
count += recurse(kid)

codepulse/src/main/resources/toserve/pages/traces/PackageWidget.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
_selected = 0,
7777
_selectedBus = new Bacon.Bus(),
7878
_collapseChildren = false,
79-
_childWidgets = [],
80-
_collapsingBus = new Bacon.Bus()
79+
_childWidgets = []
8180

8281
// ============================================================================
8382
// UI Selected Elements
@@ -195,19 +194,19 @@
195194
return self
196195
}
197196

198-
this.collapseChildren = function(arg){
197+
this.collapseChildren = function(arg, animate){
199198
if(!arguments.length) return _collapseChildren
200199

201200
if(arg == 'toggle') _collapseChildren = !_collapseChildren
202201
else _collapseChildren = arg
203202

204203
updatedCollapserState()
205204

206-
_collapsingBus.push(true)
207-
self.uiParts.childrenContainer[_collapseChildren ? 'slideUp' : 'slideDown'](
208-
/* finish animation */
209-
function(){ _collapsingBus.push(false) }
210-
)
205+
if(animate){
206+
self.uiParts.childrenContainer[_collapseChildren ? 'slideUp' : 'slideDown']()
207+
} else {
208+
self.uiParts.childrenContainer[_collapseChildren ? 'hide' : 'show']()
209+
}
211210
return self
212211
}
213212

@@ -232,11 +231,6 @@
232231
*/
233232
this.selectedProp = _selectedBus.toProperty(_selected).skipDuplicates()
234233

235-
/*
236-
Exposes (as an Rx Property) whether or not the expand/collapse animation is running
237-
*/
238-
this.collapsingProp = _collapsingBus.toProperty(false).skipDuplicates()
239-
240234
this.selectionClicks = new Bacon.Bus()
241235

242236
// ============================================================================

0 commit comments

Comments
 (0)