mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
/*
|
|
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
|
|
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
|
|
http://www.twitter.com/niklasvh
|
|
|
|
Released under MIT License
|
|
*/
|
|
_html2canvas.Renderer = function(parseQueue, options){
|
|
|
|
|
|
var queue = [];
|
|
|
|
function sortZ(zStack){
|
|
var subStacks = [],
|
|
stackValues = [],
|
|
zStackChildren = zStack.children,
|
|
s,
|
|
i,
|
|
stackLen,
|
|
zValue,
|
|
zLen,
|
|
stackChild,
|
|
b,
|
|
subStackLen;
|
|
|
|
|
|
for (s = 0, zLen = zStackChildren.length; s < zLen; s+=1){
|
|
|
|
stackChild = zStackChildren[s];
|
|
|
|
if (stackChild.children && stackChild.children.length > 0){
|
|
subStacks.push(stackChild);
|
|
stackValues.push(stackChild.zindex);
|
|
}else{
|
|
queue.push(stackChild);
|
|
}
|
|
|
|
}
|
|
|
|
stackValues.sort(function(a, b) {
|
|
return a - b;
|
|
});
|
|
|
|
for (i = 0, stackLen = stackValues.length; i < stackLen; i+=1){
|
|
zValue = stackValues[i];
|
|
for (b = 0, subStackLen = subStacks.length; b <= subStackLen; b+=1){
|
|
|
|
if (subStacks[b].zindex === zValue){
|
|
stackChild = subStacks.splice(b, 1);
|
|
sortZ(stackChild[0]);
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
sortZ(parseQueue.zIndex);
|
|
if ( typeof options.renderer._create !== "function" ) {
|
|
throw new Error("Invalid renderer defined");
|
|
}
|
|
return options.renderer._create( parseQueue, options, document, queue, _html2canvas );
|
|
|
|
};
|