From 7a4fda37b57808720454fcaab9780a2eea4caf25 Mon Sep 17 00:00:00 2001 From: thejohnhoffer Date: Tue, 30 May 2017 12:00:43 -0500 Subject: [PATCH] setPreload correctly treats both Primatives and Objects as Boolean Primatives --- src/tiledimage.js | 8 ++++---- src/viewer.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index f6337c59..bfedc96d 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -295,7 +295,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag * Draws the TiledImage to its Drawer. */ draw: function() { - if (!(this.opacity === 0 && !this._preload)) { + if (this.opacity !== 0 || this._preload) { this._midDraw = true; this._updateViewport(); this._midDraw = false; @@ -773,7 +773,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag }, /** - * @returns {Boolean} whether the tiledImage can load hidden tiles of zero opacity. + * @returns {Boolean} whether the tiledImage can load its tiles even when it has zero opacity. */ getPreload: function() { return this._preload; @@ -783,7 +783,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag * Set true to load even when hidden. Set false to block loading when hidden. */ setPreload: function(preload) { - this._preload = !!preload; + this._preload = new Boolean(preload).valueOf(); this._needsDraw = true; }, @@ -1536,7 +1536,7 @@ function compareTiles( previousBest, tile ) { } function drawTiles( tiledImage, lastDrawn ) { - if (this.opacity === 0 || lastDrawn.length === 0) { + if (tiledImage.opacity === 0 || lastDrawn.length === 0) { return; } var tile = lastDrawn[0]; diff --git a/src/viewer.js b/src/viewer.js index 78357873..2c97d31a 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1227,7 +1227,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, * @param {OpenSeadragon.Rect} [options.clip] - An area, in image pixels, to clip to * (portions of the image outside of this area will not be visible). Only works on * browsers that support the HTML5 canvas. - * @param {Number} [options.opacity=1] Default proportional opacity of the tiled images (1=opaque, 0=hidden) + * @param {Number} [options.opacity=1] Proportional opacity of the tiled images (1=opaque, 0=hidden) * @param {Boolean} [options.preload=false] Default switch for loading hidden images (true loads, false blocks) * @param {Number} [options.degrees=0] Initial rotation of the tiled image around * its top left corner in degrees.