From af2f79a3d349b04283342e8f2ac8a88d4066f900 Mon Sep 17 00:00:00 2001 From: jbphet Date: Wed, 4 Nov 2015 14:45:46 -0700 Subject: [PATCH] performance optimization - used an intermediary object in the TWEEN animator so that it doesn't have to copy the whole object for the level selection and workspace nodes, see #117 --- js/common/view/ArithmeticView.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/js/common/view/ArithmeticView.js b/js/common/view/ArithmeticView.js index 5c40c9cc..8ffc9aa8 100644 --- a/js/common/view/ArithmeticView.js +++ b/js/common/view/ArithmeticView.js @@ -64,15 +64,25 @@ define( function( require ) { multiplicationTableNode.animationOrigin = equationNode.productInput.center; // create the animators or 'tweens' that will slide the screens in and out. - var levelSelectionScreenAnimator = new TWEEN.Tween( levelSelectionNode ).easing( TWEEN.Easing.Cubic.InOut ).onComplete( function() { - levelSelectionNode.visible = ( levelSelectionNode.x === self.layoutBounds.minX ); - levelSelectionNode.pickable = levelSelectionNode.visible; // prevent interaction during animation, see issue #137 - } ); - - var workspaceNodeAnimator = new TWEEN.Tween( workspaceNode ).easing( TWEEN.Easing.Cubic.InOut ).onComplete( function() { - workspaceNode.visible = ( workspaceNode.x === self.layoutBounds.minX ); - workspaceNode.pickable = workspaceNode.visible; // prevent interaction during animation, see issue #137 - } ); + var levelSelectionScreenAnimator = new TWEEN.Tween( { x: levelSelectionNode.x } ). + easing( TWEEN.Easing.Cubic.InOut ). + onUpdate( function() { + levelSelectionNode.x = this.x; + } ). + onComplete( function() { + levelSelectionNode.visible = ( levelSelectionNode.x === self.layoutBounds.minX ); + levelSelectionNode.pickable = levelSelectionNode.visible; // prevent interaction during animation, see issue #137 + } ); + + var workspaceNodeAnimator = new TWEEN.Tween( { x: workspaceNode.x } ). + easing( TWEEN.Easing.Cubic.InOut ). + onUpdate( function() { + workspaceNode.x = this.x; + } ). + onComplete( function() { + workspaceNode.visible = ( workspaceNode.x === self.layoutBounds.minX ); + workspaceNode.pickable = workspaceNode.visible; // prevent interaction during animation, see issue #137 + } ); // variables for tracking the problem being worked on by the user. // TODO: Remove this directive once prototype below is complete