Created
April 23, 2015 16:03
-
-
Save heavysixer/9749c7ddd2b8b0fc2c77 to your computer and use it in GitHub Desktop.
Keep Angular from breaking your Parallax animations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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