Skip to content

Commit

Permalink
performance optimization - used an intermediary object in the TWEEN a…
Browse files Browse the repository at this point in the history
…nimator so that it doesn't have to copy the whole object for the level selection and workspace nodes, see #117
  • Loading branch information
jbphet committed Nov 4, 2015
1 parent 520edd7 commit af2f79a
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions js/common/view/ArithmeticView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af2f79a

Please sign in to comment.