From ec0f55098abbe7cceb194c8f44c0d1a5416355c7 Mon Sep 17 00:00:00 2001 From: Nelson Campos Date: Fri, 13 Apr 2018 17:51:43 +0100 Subject: [PATCH] Simplifies viewport setFlip function. --- src/viewport.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index 41ea7246..a3e207b8 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -1549,29 +1549,27 @@ $.Viewport.prototype = { * @return {OpenSeadragon.Viewport} Chainable. */ setFlip: function( state ) { - if ( this.flipped != state ) { - this.flipped = state; - this.viewer.forceRedraw(); - - /** - * Raised when flip state has been changed. - * - * @event flip - * @memberof OpenSeadragon.Viewer - * @type {object} - * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. - * @property {Number} flipped - The flip state after this change. - * @property {?Object} userData - Arbitrary subscriber-defined object. - */ - this.viewer.raiseEvent('flip', {"flipped": state}); - } else { - this.flipped = state; + if ( this.flipped === state ) { + return this; } + this.flipped = state; if(this.viewer.navigator){ this.viewer.navigator.setFlip(this.getFlip()); } this.viewer.forceRedraw(); + + /** + * Raised when flip state has been changed. + * + * @event flip + * @memberof OpenSeadragon.Viewer + * @type {object} + * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. + * @property {Number} flipped - The flip state after this change. + * @property {?Object} userData - Arbitrary subscriber-defined object. + */ + this.viewer.raiseEvent('flip', {"flipped": state}); return this; }