I believe each time you go back and forth to planetary view, view-planetary.html
unloads and loads again but the plantery.js event (planet.draw(canvas)
) in your link function still remains in memory and hence it flickers because of multiple instances of planet.draw running. To get rid of this issue (which is a most common thing people forget to do especially when they bind external events angular is unaware of), we need to watch for the $destroy
event on the element (canvas). Put below code inside a link method of planetary directive.
element.on('$destroy', function() {
// I did not find the destroy method to unload the planet in planetary.js
// If you find it then put it here
// For example, planet.destroy(canvas);
});