Skip to content

Commit bbd7528

Browse files
committed
jquery.plugin.html2canvas: add profiling option, tests: enable profiling
in case you run the tests in firefox and have firebug installed and active you now get a profiling run of html2canvas ;)
1 parent 8bbbace commit bbd7528

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/plugins/jquery.plugin.html2canvas.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*/
44
(function( $ ){
55
$.fn.html2canvas = function(options) {
6+
if (options && options.profile && window.console && window.console.profile) {
7+
console.profile();
8+
}
69
var date = new Date(),
710
$message = null,
811
timeoutTimer = false,
@@ -14,20 +17,17 @@
1417
$canvas = $(html2canvas.Renderer(queue, options)),
1518
finishTime = new Date();
1619

20+
if (options && options.profile && window.console && window.console.profileEnd) {
21+
console.profileEnd();
22+
}
1723
$canvas.css({ position: 'absolute', left: 0, top: 0 }).appendTo(document.body);
1824
$canvas.siblings().toggle();
1925

2026
$(window).click(function(){
21-
if (!$canvas.is(':visible')){
2227
$canvas.toggle().siblings().toggle();
23-
throwMessage("Canvas Render visible");
24-
} else{
25-
$canvas.siblings().toggle();
26-
$canvas.toggle();
27-
throwMessage("Canvas Render hidden");
28-
}
28+
throwMessage("Canvas Render " + ($canvas.is(':visible') ? "visible" : "hidden"));
2929
});
30-
throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)/1000) + " seconds<br />",4000);
30+
throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)) + " ms<br />",4000);
3131
}
3232
}, options));
3333

@@ -36,6 +36,7 @@
3636
timeoutTimer = window.setTimeout(function(){
3737
$message.fadeOut(function(){
3838
$message.remove();
39+
$message = null;
3940
});
4041
},duration || 2000);
4142
if ($message)
@@ -55,8 +56,10 @@
5556
width:'auto',
5657
height:'auto',
5758
textAlign:'center',
58-
textDecoration:'none'
59-
}).hide().fadeIn().appendTo('body');
59+
textDecoration:'none',
60+
display:'none'
61+
}).appendTo(document.body).fadeIn();
62+
html2canvas.log(msg);
6063
}
6164
};
6265
})( jQuery );

tests/test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
}
1919
setTimeout(function() {
2020
$(document.body).html2canvas({
21-
logging: true
21+
logging: true,
22+
profile: true
2223
});
2324
}, 100);
2425
};
25-
}(document, window));
26+
}(document, window));

0 commit comments

Comments
 (0)