mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Fix z-index ordering bug
This commit is contained in:
parent
443fd17a12
commit
46cc8b6975
@ -1,4 +1,13 @@
|
|||||||
_html2canvas.Renderer = function(parseQueue, options){
|
_html2canvas.Renderer = function(parseQueue, options){
|
||||||
|
function sortZindex(a, b) {
|
||||||
|
if (a === 'children') {
|
||||||
|
return -1;
|
||||||
|
} else if (b === 'children') {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// http://www.w3.org/TR/CSS21/zindex.html
|
// http://www.w3.org/TR/CSS21/zindex.html
|
||||||
function createRenderQueue(parseQueue) {
|
function createRenderQueue(parseQueue) {
|
||||||
@ -16,8 +25,9 @@ _html2canvas.Renderer = function(parseQueue, options){
|
|||||||
childrenDest = specialParent; // where children without z-index should be pushed into
|
childrenDest = specialParent; // where children without z-index should be pushed into
|
||||||
|
|
||||||
if (node.zIndex.ownStacking) {
|
if (node.zIndex.ownStacking) {
|
||||||
// '!' comes before numbers in sorted array
|
contextForChildren = stub.context = {
|
||||||
contextForChildren = stub.context = { '!': [{node:node, children: []}]};
|
children: [{node:node, children: []}]
|
||||||
|
};
|
||||||
childrenDest = undefined;
|
childrenDest = undefined;
|
||||||
} else if (isPositioned || isFloated) {
|
} else if (isPositioned || isFloated) {
|
||||||
childrenDest = stub.children = [];
|
childrenDest = stub.children = [];
|
||||||
@ -39,7 +49,7 @@ _html2canvas.Renderer = function(parseQueue, options){
|
|||||||
})(parseQueue);
|
})(parseQueue);
|
||||||
|
|
||||||
function sortZ(context) {
|
function sortZ(context) {
|
||||||
Object.keys(context).sort(function(a, b) { return a - b; }).forEach(function(zi) {
|
Object.keys(context).sort(sortZindex).forEach(function(zi) {
|
||||||
var nonPositioned = [],
|
var nonPositioned = [],
|
||||||
floated = [],
|
floated = [],
|
||||||
positioned = [],
|
positioned = [],
|
||||||
|
Loading…
Reference in New Issue
Block a user