diff --git a/src/drawer.js b/src/drawer.js index b8d87aba..3ebb54ca 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -288,13 +288,13 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{ }, // private - drawPlaceholder: function(rect) { + drawPlaceholder: function(rect, fillStyle) { if (!this.useCanvas) { return; } + this.context.fillStyle = fillStyle || "#FFFFFF"; this.context.fillRect(rect.x, rect.y, rect.width, rect.height); - this.context.fillStyle = "#000000"; }, // private diff --git a/src/openseadragon.js b/src/openseadragon.js index 8d231cbe..e0ff9c9b 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -206,6 +206,9 @@ * @property {Number} [opacity=1] * Opacity of the drawer (1=opaque, 0=transparent) * + * @property {String|Object} [placeholderFillStyle=null] + * Draws a colored rectangle behind the tile if it is not loaded yet. + * * @property {Number} [degrees=0] * Initial rotation. * @@ -262,7 +265,7 @@ * Possible subproperties (Numbers, in screen coordinates): left, top, right, bottom. * * @property {Number} [imageLoaderLimit=0] - * The maximum number of image requests to make concurrently. By default + * The maximum number of image requests to make concurrently. By default * it is set to 0 allowing the browser to make the maximum number of * image requests in parallel as allowed by the browsers policy. * @@ -1017,6 +1020,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ // APPEARANCE opacity: 1, + placeholderFillStyle: null, //REFERENCE STRIP SETTINGS showReferenceStrip: false, diff --git a/src/tiledimage.js b/src/tiledimage.js index 464f2477..14f342f0 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -65,6 +65,7 @@ * @param {Boolean} [options.alwaysBlend] - See {@link OpenSeadragon.Options}. * @param {Number} [options.minPixelRatio] - See {@link OpenSeadragon.Options}. * @param {Boolean} [options.debugMode] - See {@link OpenSeadragon.Options}. + * @param {String|Object} [options.placeholderFillStyle] - See {@link OpenSeadragon.Options}. * @param {String|Boolean} [options.crossOriginPolicy] - See {@link OpenSeadragon.Options}. */ $.TiledImage = function( options ) { @@ -126,21 +127,22 @@ $.TiledImage = function( options ) { coverage: {}, // A '3d' dictionary [level][x][y] --> Boolean. lastDrawn: [], // An unordered list of Tiles drawn last frame. lastResetTime: 0, // Last time for which the tiledImage was reset. - _midDraw: false, // Is the tiledImage currently updating the viewport? - _needsDraw: true, // Does the tiledImage need to update the viewport again? + _midDraw: false, // Is the tiledImage currently updating the viewport? + _needsDraw: true, // Does the tiledImage need to update the viewport again? //configurable settings - springStiffness: $.DEFAULT_SETTINGS.springStiffness, - animationTime: $.DEFAULT_SETTINGS.animationTime, - minZoomImageRatio: $.DEFAULT_SETTINGS.minZoomImageRatio, - wrapHorizontal: $.DEFAULT_SETTINGS.wrapHorizontal, - wrapVertical: $.DEFAULT_SETTINGS.wrapVertical, - immediateRender: $.DEFAULT_SETTINGS.immediateRender, - blendTime: $.DEFAULT_SETTINGS.blendTime, - alwaysBlend: $.DEFAULT_SETTINGS.alwaysBlend, - minPixelRatio: $.DEFAULT_SETTINGS.minPixelRatio, - debugMode: $.DEFAULT_SETTINGS.debugMode, - crossOriginPolicy: $.DEFAULT_SETTINGS.crossOriginPolicy + springStiffness: $.DEFAULT_SETTINGS.springStiffness, + animationTime: $.DEFAULT_SETTINGS.animationTime, + minZoomImageRatio: $.DEFAULT_SETTINGS.minZoomImageRatio, + wrapHorizontal: $.DEFAULT_SETTINGS.wrapHorizontal, + wrapVertical: $.DEFAULT_SETTINGS.wrapVertical, + immediateRender: $.DEFAULT_SETTINGS.immediateRender, + blendTime: $.DEFAULT_SETTINGS.blendTime, + alwaysBlend: $.DEFAULT_SETTINGS.alwaysBlend, + minPixelRatio: $.DEFAULT_SETTINGS.minPixelRatio, + debugMode: $.DEFAULT_SETTINGS.debugMode, + crossOriginPolicy: $.DEFAULT_SETTINGS.crossOriginPolicy, + placeholderFillStyle: $.DEFAULT_SETTINGS.placeholderFillStyle }, options ); @@ -1148,7 +1150,7 @@ function compareTiles( previousBest, tile ) { return previousBest; } -function drawTiles( tiledImage, lastDrawn ){ +function drawTiles( tiledImage, lastDrawn ) { var i, tile, tileKey, @@ -1180,11 +1182,11 @@ function drawTiles( tiledImage, lastDrawn ){ needsRestore = true; } - if ( lastDrawn.length === 0 ) { + if ( tiledImage.placeholderFillStyle && lastDrawn.length === 0 ) { tiledImage._drawer.saveContext(); var placeholderRect = boxToDrawerRectangle( tiledImage.getBounds(true) ); - tiledImage._drawer.drawPlaceholder(placeholderRect); + tiledImage._drawer.drawPlaceholder(placeholderRect, tiledImage.placeholderFillStyle); needsRestore = true; } diff --git a/src/viewer.js b/src/viewer.js index 7b269350..562b50b2 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1294,7 +1294,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, alwaysBlend: _this.alwaysBlend, minPixelRatio: _this.minPixelRatio, crossOriginPolicy: _this.crossOriginPolicy, - debugMode: _this.debugMode + debugMode: _this.debugMode, + placeholderFillStyle: _this.placeholderFillStyle }); _this.world.addItem( tiledImage, {