Skip to content

Commit

Permalink
added option to control crossOrigin setting on canvas images (fixes D…
Browse files Browse the repository at this point in the history
  • Loading branch information
jezerinac committed Oct 8, 2016
1 parent 4732291 commit 61bff66
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/js/diva.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = diva;
enableImageTitles: true, // Adds "Page {n}" title to page images if true
enableKeyScroll: true, // Captures scrolling using the arrow and page up/down keys regardless of page focus. When off, defers to default browser scrolling behavior.
enableLinkIcon: true, // Controls the visibility of the link icon
enableCrossOrigin: true, // if enabled images on diva canvas will have crossOrigin = "anonymous"
enableNonPagedVisibilityIcon: true, // Controls the visibility of the icon to toggle the visibility of non-paged pages. (Automatically hidden if no 'non-paged' pages).
enableSpaceScroll: false, // Scrolling down by pressing the space key
enableToolbar: true, // Enables the toolbar. Note that disabling this means you have to handle all controls yourself.
Expand Down
5 changes: 4 additions & 1 deletion source/js/image-request-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function ImageRequestHandler(options)
{
// Initiate the request
this._image = new Image();
this._image.crossOrigin = "anonymous";
if (options.enableCrossOrigin)
{
this._image.crossOrigin = "anonymous";
}
this._image.onload = this._handleLoad.bind(this);
this._image.onerror = this._handleError.bind(this);
this._image.src = options.url;
Expand Down
2 changes: 2 additions & 0 deletions source/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Renderer(options, hooks)
this._viewport = options.viewport;
this._outerElement = options.outerElement;
this._documentElement = options.innerElement;
this._enableCrossOrigin = options.enableCrossOrigin;

this._hooks = hooks || {};

Expand Down Expand Up @@ -287,6 +288,7 @@ Renderer.prototype._initiateTileRequests = function(pages)
newPendingRequests[source.url] = new ImageRequestHandler({
url: source.url,
timeoutTime: REQUEST_DEBOUNCE_INTERVAL,
enableCrossOrigin: this._enableCrossOrigin,
load: function (img)
{
delete this._pendingRequests[source.url];
Expand Down
3 changes: 2 additions & 1 deletion source/js/viewer-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ function ViewerCore(element, options, publicInstance)
var options = {
viewport: viewerState.viewport,
outerElement: viewerState.outerElement,
innerElement: viewerState.innerElement
innerElement: viewerState.innerElement,
enableCrossOrigin: settings.options.enableCrossOrigin
};

var hooks = {
Expand Down

0 comments on commit 61bff66

Please sign in to comment.