From 546efcc1dbafac20caee6ac11ae55d12311dc9a3 Mon Sep 17 00:00:00 2001 From: Nelson Campos Date: Fri, 19 Oct 2018 10:58:47 +0100 Subject: [PATCH] Fix undefined return from getFlip Navigator setFlip was looking for tiledImage flip state using the getFlip method. The item this.viewer.world._items[0] can be undefined and trying to use its methods would fail. --- src/navigator.js | 2 +- src/viewer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index bb4e08d6..4b2018fb 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -284,7 +284,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* setFlip: function(state) { this.viewport.setFlip(state); - var flip = ((this.viewport.getFlip() && !this.viewer.world._items[0].getFlip()) || (!this.viewport.getFlip() && this.viewer.world._items[0].getFlip())); + var flip = ((this.viewport.getFlip() && this.viewer.world._items[0] && !this.viewer.world._items[0].getFlip()) || (!this.viewport.getFlip() && this.viewer.world._items[0] && this.viewer.world._items[0].getFlip())); this.setDisplayTransform(flip ? "scale(-1,1)" : "scale(1,1)"); return this; }, diff --git a/src/viewer.js b/src/viewer.js index f622829c..ac3701b4 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -3367,7 +3367,7 @@ function updateOnce( viewer ) { THIS[ viewer.hash ].animating = animated; // Update navigator flip transformation - if (viewer.navigator && viewer.viewport != "undefined"){ + if (viewer.navigator && viewer.viewport != undefined){ viewer.navigator.setFlip(viewer.viewport.getFlip()); } //viewer.profiler.endUpdate();