Skip to content

Commit

Permalink
Properly dispose Drag and HoverColor behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpeiris committed Nov 15, 2016
1 parent 4bd7ffa commit 2863233
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utilities/behaviors/Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,9 @@ altspace.utilities.behaviors.Drag = function (config) {
object3d.addEventListener('cursordown', startDrag);
}

return { awake: awake, start: start, type: 'Drag' };
function dispose() {
object3d.removeEventListener('cursordown', startDrag);
}

return { awake: awake, start: start, dispose: dispose, type: 'Drag' };
};
8 changes: 8 additions & 0 deletions src/utilities/behaviors/HoverColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,17 @@ altspace.utilities.behaviors.HoverColor = function(config){
}
}

function dispose() {
object3d.removeEventListener('cursordown', cursordown);
scene.removeEventListener('cursorup', cursorupScene);
object3d.removeEventListener('cursorenter', cursorenter);
object3d.removeEventListener('cursorleave', cursorleave);
}

return {
//no update method, event-driven
awake: awake,
dispose: dispose,
type: 'HoverColor'
};

Expand Down

0 comments on commit 2863233

Please sign in to comment.