From 4b9d0a67d2115a4b1ccc7f0364cf90b920b6e885 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 20 Sep 2018 23:27:10 +0200 Subject: [PATCH] Inline the 'scalechanging' event dispatching in `BaseViewer._setScaleUpdatePages` With only *one* event now being dispatched when the scale changes, in combination with there only being two call-sites, it doesn't seem necessary to keep the helper method for dispatching the 'scalechanging' event. --- web/base_viewer.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index bd6c1bcec..9588d75dc 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -538,20 +538,16 @@ class BaseViewer { throw new Error('Not implemented: _scrollIntoView'); } - _setScaleDispatchEvent(newScale, newValue, preset = false) { - this.eventBus.dispatch('scalechanging', { - source: this, - scale: newScale, - presetValue: preset ? newValue : undefined, - }); - } - _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) { this._currentScaleValue = newValue.toString(); if (isSameScale(this._currentScale, newScale)) { if (preset) { - this._setScaleDispatchEvent(newScale, newValue, true); + this.eventBus.dispatch('scalechanging', { + source: this, + scale: newScale, + presetValue: newValue, + }); } return; } @@ -576,7 +572,11 @@ class BaseViewer { }); } - this._setScaleDispatchEvent(newScale, newValue, preset); + this.eventBus.dispatch('scalechanging', { + source: this, + scale: newScale, + presetValue: preset ? newValue : undefined, + }); if (this.defaultRenderingQueue) { this.update();