Cache result of getMetrics

This commit is contained in:
Eric Rosenbaum 2017-09-18 14:36:55 -04:00
parent d71c0e01d1
commit 53101f763f
2 changed files with 6 additions and 4 deletions

View file

@ -253,8 +253,9 @@ Blockly.HorizontalFlyout.prototype.scrollTo = function(pos) {
// Make sure not to set the scroll target past the farthest point we can
// scroll to, i.e. the content width minus the view width
var contentWidth = this.workspace_.getMetrics().contentWidth;
var viewWidth = this.workspace_.getMetrics().viewWidth;
var metrics = this.workspace_.getMetrics();
var contentWidth = metrics.contentWidth;
var viewWidth = metrics.viewWidth;
this.scrollTarget = Math.min(this.scrollTarget, contentWidth - viewWidth);
this.step();

View file

@ -341,8 +341,9 @@ Blockly.VerticalFlyout.prototype.scrollTo = function(pos) {
// Make sure not to set the scroll target below the lowest point we can
// scroll to, i.e. the content height minus the view height
var contentHeight = this.workspace_.getMetrics().contentHeight;
var viewHeight = this.workspace_.getMetrics().viewHeight;
var metrics = this.workspace_.getMetrics();
var contentHeight = metrics.contentHeight;
var viewHeight = metrics.viewHeight;
this.scrollTarget = Math.min(this.scrollTarget, contentHeight - viewHeight);
this.step();