Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

try/catch to avoid Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information...
commit 1ab552f8aa9289ec0c692bf28fade97f915e6ac8 1 parent 5bd69f4
@rwaldron rwaldron authored
Showing with 16 additions and 10 deletions.
  1. +16 −10 performance/src/sprite.js
View
26 performance/src/sprite.js
@@ -11,16 +11,22 @@ function Renderer( src ) {
Renderer.prototype = {
render: function( frame, bounds, context ) {
- context.drawImage(
- // Draw the entity...
- this.image,
- // On the cell...
- frame.left, frame.top,
- frame.width, frame.height,
- // Within the current calculated bounds...
- bounds.left, bounds.top,
- frame.width, frame.height
- );
+
+ // Wrap the drawImage call in try/catch to avoid
+ // Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
+ // when the canvas and image have gone away
+ try {
+ context.drawImage(
+ // Draw the entity...
+ this.image,
+ // On the cell...
+ frame.left, frame.top,
+ frame.width, frame.height,
+ // Within the current calculated bounds...
+ bounds.left, bounds.top,
+ frame.width, frame.height
+ );
+ } catch ( e ) {}
return this;
}
Please sign in to comment.
Something went wrong with that request. Please try again.