64 lines
1.6 KiB
Dart
Raw Normal View History

library scroll_app;
import 'dart:async';
import 'dart:html';
import 'package:angular/angular.dart';
import 'package:e2e_test_lib/benchmark_util.dart';
@Component(
selector: 'scroll-app',
template: '''
<div>
<div style="display: flex">
<scroll-area scroll-top="scrollTop"></scroll-area>
<div style="padding-left: 20px">
<button id='run-btn'>Run</button>
<button id='reset-btn'>Reset</button>
</div>
</div>
<div ng-if="scrollAreas.length > 0">
<p>Following tables are only here to add weight to the UI:</p>
<scroll-area ng-repeat="scrollArea in scrollAreas"></scroll-area>
</div>
</div>
''')
class App implements ShadowRootAware {
final VmTurnZone ngZone;
List<int> scrollAreas;
int scrollTop = 0;
int iterationCount;
int scrollIncrement;
App(this.ngZone) {
int appSize = getIntParameter('appSize');
iterationCount = getIntParameter('iterationCount');
scrollIncrement = getIntParameter('scrollIncrement');
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
scrollAreas = new List.generate(appSize, (i) => i);
}
@override
void onShadowRoot(ShadowRoot shadowRoot) {
bindAction('scroll-app /deep/ #run-btn', () {
runBenchmark();
});
bindAction('scroll-app /deep/ #reset-btn', () {
scrollTop = 0;
});
}
void runBenchmark() {
int n = iterationCount;
scheduleScroll() {
new Future(() {
scrollTop += scrollIncrement;
n--;
if (n > 0) {
scheduleScroll();
}
});
}
scheduleScroll();
}
}