mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
coding optimizations
This commit is contained in:
parent
16d3bef255
commit
65746bd2e3
12
src/Parse.js
12
src/Parse.js
@ -316,10 +316,9 @@ _html2canvas.Parse = function (images, options) {
|
||||
|
||||
function setZ(element, stack, parentStack){
|
||||
var newContext,
|
||||
position = stack.cssPosition,
|
||||
zIndex = getCSS(element, 'zIndex'),
|
||||
isPositioned = stack.cssPosition !== 'static',
|
||||
zIndex = isPositioned ? getCSS(element, 'zIndex') : 'auto', // z-index only applies to positioned elements.
|
||||
opacity = getCSS(element, 'opacity'), // can't use stack.opacity because it's blended
|
||||
isPositioned = position !== 'static',
|
||||
isFloated = getCSS(element, 'cssFloat') !== 'none';
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
|
||||
@ -329,15 +328,11 @@ _html2canvas.Parse = function (images, options) {
|
||||
// elements with an opacity value less than 1. (See the specification for opacity),
|
||||
// on mobile WebKit and Chrome 22+, position: fixed always creates a new stacking context, even when z-index is "auto" (See this post)
|
||||
|
||||
// z-index only applies to positioned elements.
|
||||
// however, firefox may return the value set in CSS even if it's not positioned
|
||||
if (!isPositioned) { zIndex = 0 ;}
|
||||
stack.zIndex = newContext = h2czContext(zIndex);
|
||||
newContext.isPositioned = isPositioned;
|
||||
newContext.isFloated = isFloated;
|
||||
|
||||
if (!parentStack || (zIndex !== 'auto' && isPositioned) ||
|
||||
(opacity && Number(opacity) < 1)) {
|
||||
if (zIndex !== 'auto' || opacity < 1) {
|
||||
newContext.ownStacking = true;
|
||||
}
|
||||
|
||||
@ -967,7 +962,6 @@ _html2canvas.Parse = function (images, options) {
|
||||
|
||||
var ctx = h2cRenderContext((!parentStack) ? documentWidth() : bounds.width , (!parentStack) ? documentHeight() : bounds.height),
|
||||
stack = {
|
||||
el: element, // very useful when debugging
|
||||
ctx: ctx,
|
||||
opacity: setOpacity(ctx, element, parentStack),
|
||||
cssPosition: getCSS(element, "position"),
|
||||
|
@ -8,15 +8,13 @@ _html2canvas.Renderer = function(parseQueue, options){
|
||||
rootContext = (function buildStackingContext(rootNode) {
|
||||
var rootContext = {};
|
||||
function insert(context, node, specialParent) {
|
||||
var zi = node.zIndex.zindex,
|
||||
var zi = (node.zIndex.zindex === 'auto') ? 0 : Number(node.zIndex.zindex),
|
||||
contextForChildren = context, // the stacking context for children
|
||||
isPositioned = node.zIndex.isPositioned,
|
||||
isFloated = node.zIndex.isFloated,
|
||||
stub = {node: node},
|
||||
childrenDest; // where children without z-index should be pushed into
|
||||
|
||||
if (zi === 'auto') { zi = 0; }
|
||||
zi = Number(zi);
|
||||
if (!context[zi]) { context[zi] = []; }
|
||||
if (node.zIndex.ownStacking) {
|
||||
contextForChildren = stub.context = { 0: [{node:node}]};
|
||||
|
Loading…
Reference in New Issue
Block a user