Skip to content

Instantly share code, notes, and snippets.

@heavysixer
Created April 23, 2015 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heavysixer/9749c7ddd2b8b0fc2c77 to your computer and use it in GitHub Desktop.
Save heavysixer/9749c7ddd2b8b0fc2c77 to your computer and use it in GitHub Desktop.
Keep Angular from breaking your Parallax animations
angular.module('app.directives')
.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined') {
/*
Once Angular adds something to its template cache it can render slightly different
the next time it is recalled. This can break functionality that expects the CSS of elements
to be exactly as it was coded (for example parallax). To prevent a specific file from being added
to your template cache you can remove it as needed this way:
*/
if(current.templateUrl === 'views/modules/MY_FILE/index.html'){
$templateCache.remove(current.templateUrl);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment