Commit 9cf9ca1a by Don Mitchell

Use try/catch to detect undefined globals for canvas

parent e85f4866
......@@ -3339,7 +3339,9 @@ schematic = (function() {
}
// add method to canvas to compute relative coords for event
if (HTMLCanvasElement) HTMLCanvasElement.prototype.relMouseCoords = function(event){
try {
if (HTMLCanvasElement)
HTMLCanvasElement.prototype.relMouseCoords = function(event){
// run up the DOM tree to figure out coords for top,left of canvas
var totalOffsetX = 0;
var totalOffsetY = 0;
......@@ -3357,6 +3359,9 @@ schematic = (function() {
this.page_x = event.pageX;
this.page_y = event.pageY;
}
}
catch (err) { // ignore
}
///////////////////////////////////////////////////////////////////////////////
//
......@@ -4091,6 +4096,8 @@ schematic = (function() {
// add dashed lines!
// from http://davidowens.wordpress.com/2010/09/07/html-5-canvas-and-dashed-lines/
try {
if (CanvasRenderingContext2D)
CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) {
// Our growth rate for our line can be one of the following:
// (+,+), (+,-), (-,+), (-,-)
......@@ -4132,7 +4139,9 @@ schematic = (function() {
dash = !dash;
}
};
}
catch (err) { //noop
}
// given a range of values, return a new range [vmin',vmax'] where the limits
// have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator
function view_limits(vmin,vmax) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment