mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Moved renderer logic to renderer.js
This commit is contained in:
parent
816ff6d3c5
commit
c3e9636e4f
@ -1,5 +1,5 @@
|
||||
_html2canvas.Renderer = function(parseQueue, options){
|
||||
var queue = [];
|
||||
var queue = [], renderer;
|
||||
|
||||
function sortZ(zStack){
|
||||
var subStacks = [],
|
||||
@ -47,11 +47,20 @@ _html2canvas.Renderer = function(parseQueue, options){
|
||||
|
||||
}
|
||||
|
||||
|
||||
sortZ(parseQueue.zIndex);
|
||||
if ( typeof options._renderer._create !== "function" ) {
|
||||
|
||||
if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) {
|
||||
renderer = _html2canvas.Renderer[options.renderer](options);
|
||||
} else if (typeof options.renderer === "function") {
|
||||
renderer = options.renderer(options);
|
||||
} else {
|
||||
throw new Error("Unknown renderer");
|
||||
}
|
||||
|
||||
if ( typeof renderer._create !== "function" ) {
|
||||
throw new Error("Invalid renderer defined");
|
||||
}
|
||||
return options._renderer._create( parseQueue, options, document, queue, _html2canvas );
|
||||
|
||||
return renderer._create( parseQueue, options, document, queue, _html2canvas );
|
||||
|
||||
};
|
||||
|
19
src/Util.js
19
src/Util.js
@ -1,5 +1,4 @@
|
||||
html2canvas = function( elements, opts ) {
|
||||
|
||||
window.html2canvas = function(elements, opts) {
|
||||
var queue,
|
||||
canvas,
|
||||
options = {
|
||||
@ -8,7 +7,7 @@ html2canvas = function( elements, opts ) {
|
||||
elements: elements,
|
||||
|
||||
// preload options
|
||||
proxy: "http://html2canvas.appspot.com/",
|
||||
proxy: "",
|
||||
timeout: 0, // no timeout
|
||||
useCORS: false, // try to load images as CORS (where available), before falling back to proxy
|
||||
allowTaint: false, // whether to allow images to taint the canvas, won't need proxy if set to true
|
||||
@ -27,18 +26,10 @@ html2canvas = function( elements, opts ) {
|
||||
height: null,
|
||||
taintTest: true, // do a taint test with all images before applying to canvas
|
||||
renderer: "Canvas"
|
||||
}, renderer;
|
||||
};
|
||||
|
||||
options = _html2canvas.Util.Extend(opts, options);
|
||||
|
||||
if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) {
|
||||
options._renderer = _html2canvas.Renderer[options.renderer]( options );
|
||||
} else if (typeof options.renderer === "function") {
|
||||
options._renderer = options.renderer( options );
|
||||
} else {
|
||||
throw("Unknown renderer");
|
||||
}
|
||||
|
||||
_html2canvas.logging = options.logging;
|
||||
options.complete = function( images ) {
|
||||
|
||||
@ -83,7 +74,7 @@ html2canvas = function( elements, opts ) {
|
||||
};
|
||||
};
|
||||
|
||||
html2canvas.log = h2clog; // for renderers
|
||||
html2canvas.Renderer = {
|
||||
window.html2canvas.log = h2clog; // for renderers
|
||||
window.html2canvas.Renderer = {
|
||||
Canvas: undefined // We are assuming this will be used
|
||||
};
|
Loading…
Reference in New Issue
Block a user