mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Refactoring
This commit is contained in:
parent
2777a3e079
commit
c9e2fc27c8
23
src/Core.js
23
src/Core.js
@ -20,6 +20,10 @@ _html2canvas.Util.trimText = (function(isNative){
|
||||
};
|
||||
})(String.prototype.trim);
|
||||
|
||||
_html2canvas.Util.asFloat = function(v) {
|
||||
return parseFloat(v);
|
||||
};
|
||||
|
||||
(function() {
|
||||
// TODO: support all possible length values
|
||||
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') {
|
||||
output_width = target_width;
|
||||
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_width = target_height * current_ratio;
|
||||
} else {
|
||||
output_width = target_width;
|
||||
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 ) {
|
||||
@ -356,13 +360,9 @@ _html2canvas.Util.Extend = function (options, defaults) {
|
||||
_html2canvas.Util.Children = function( elem ) {
|
||||
var children;
|
||||
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 = [];
|
||||
|
||||
if (array !== null) {
|
||||
|
||||
(function(first, second ) {
|
||||
var i = first.length,
|
||||
j = 0;
|
||||
@ -371,7 +371,6 @@ _html2canvas.Util.Children = function( elem ) {
|
||||
for (var l = second.length; j < l; j++) {
|
||||
first[i++] = second[j];
|
||||
}
|
||||
|
||||
} else {
|
||||
while (second[j] !== undefined) {
|
||||
first[i++] = second[j++];
|
||||
@ -382,9 +381,7 @@ _html2canvas.Util.Children = function( elem ) {
|
||||
|
||||
return first;
|
||||
})(ret, array);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
})(elem.childNodes);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user