From d86c3054ec7c9314bbb0f9c961a730a87aba83be Mon Sep 17 00:00:00 2001 From: samreid Date: Wed, 14 Feb 2018 10:20:39 -0700 Subject: [PATCH] Eliminated memory leak, see https://github.com/phetsims/friction/issues/64 --- js/friction/view/magnifier/AtomNode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/friction/view/magnifier/AtomNode.js b/js/friction/view/magnifier/AtomNode.js index c6c840e2..3a9445aa 100644 --- a/js/friction/view/magnifier/AtomNode.js +++ b/js/friction/view/magnifier/AtomNode.js @@ -111,6 +111,7 @@ define( function( require ) { * TODO: visibility annotation and documentation */ evaporate: function() { + assert && assert( !this.isEvaporated, 'AtomNode was already evaporated' ); var self = this; this.isEvaporated = true; @@ -125,8 +126,7 @@ define( function( require ) { self.originX += dx; self.originY -= dy; - // TODO: memory leak for atoms moving to the left? - if ( self.originX > 4 * self.model.width ) { + if ( Math.abs( self.originX ) > 4 * self.model.width ) { self.model.stepEmitter.removeListener( self.handler ); self.setVisible( false ); }