mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Refactoring
This commit is contained in:
parent
25abef772e
commit
55641a0fd8
23
src/Core.js
23
src/Core.js
@ -20,6 +20,10 @@ _html2canvas.Util.trimText = (function(isNative){
|
|||||||
};
|
};
|
||||||
})(String.prototype.trim);
|
})(String.prototype.trim);
|
||||||
|
|
||||||
|
_html2canvas.Util.asFloat = function(v) {
|
||||||
|
return parseFloat(v);
|
||||||
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// TODO: support all possible length values
|
// TODO: support all possible length values
|
||||||
var TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g;
|
var TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g;
|
||||||
@ -256,18 +260,18 @@ _html2canvas.Util.resizeBounds = function( current_width, current_height, target
|
|||||||
if(!stretch_mode || stretch_mode === 'auto') {
|
if(!stretch_mode || stretch_mode === 'auto') {
|
||||||
output_width = target_width;
|
output_width = target_width;
|
||||||
output_height = target_height;
|
output_height = target_height;
|
||||||
|
} else if(target_ratio < current_ratio ^ stretch_mode === 'contain') {
|
||||||
} else {
|
|
||||||
if(target_ratio < current_ratio ^ stretch_mode === 'contain') {
|
|
||||||
output_height = target_height;
|
output_height = target_height;
|
||||||
output_width = target_height * current_ratio;
|
output_width = target_height * current_ratio;
|
||||||
} else {
|
} else {
|
||||||
output_width = target_width;
|
output_width = target_width;
|
||||||
output_height = target_width / current_ratio;
|
output_height = target_width / current_ratio;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return { width: output_width, height: output_height };
|
return {
|
||||||
|
width: output_width,
|
||||||
|
height: output_height
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function backgroundBoundsFactory( prop, el, bounds, image, imageIndex, backgroundSize ) {
|
function backgroundBoundsFactory( prop, el, bounds, image, imageIndex, backgroundSize ) {
|
||||||
@ -356,13 +360,9 @@ _html2canvas.Util.Extend = function (options, defaults) {
|
|||||||
_html2canvas.Util.Children = function( elem ) {
|
_html2canvas.Util.Children = function( elem ) {
|
||||||
var children;
|
var children;
|
||||||
try {
|
try {
|
||||||
|
children = (elem.nodeName && elem.nodeName.toUpperCase() === "IFRAME") ? elem.contentDocument || elem.contentWindow.document : (function(array) {
|
||||||
children = (elem.nodeName && elem.nodeName.toUpperCase() === "IFRAME") ?
|
|
||||||
elem.contentDocument || elem.contentWindow.document : (function( array ){
|
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|
||||||
if (array !== null) {
|
if (array !== null) {
|
||||||
|
|
||||||
(function(first, second ) {
|
(function(first, second ) {
|
||||||
var i = first.length,
|
var i = first.length,
|
||||||
j = 0;
|
j = 0;
|
||||||
@ -371,7 +371,6 @@ _html2canvas.Util.Children = function( elem ) {
|
|||||||
for (var l = second.length; j < l; j++) {
|
for (var l = second.length; j < l; j++) {
|
||||||
first[i++] = second[j];
|
first[i++] = second[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
while (second[j] !== undefined) {
|
while (second[j] !== undefined) {
|
||||||
first[i++] = second[j++];
|
first[i++] = second[j++];
|
||||||
@ -382,9 +381,7 @@ _html2canvas.Util.Children = function( elem ) {
|
|||||||
|
|
||||||
return first;
|
return first;
|
||||||
})(ret, array);
|
})(ret, array);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
})(elem.childNodes);
|
})(elem.childNodes);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user