When using the function to switch images as shown below, I want to check if the image is already in the cache to prevent showing the css .loading class. The .complete() object just made a lot of trouble but I couldn't use it probably.
The switchImage Function is fired when pressing a thumbnail or a prev/next button. Is their any solution to check whether the image/url I want to load is already in the cache?
- switchImage = function(){
- var currentPath = $active.attr("href");
- $('#largeImg').fadeOut('fast',loadContent);
-
- $(".thumbs a").removeClass('active');
- $active.addClass('active');
- function loadContent() {
- $('.loading').fadeIn('fast');
-
- $("#largeImg").attr( "src", currentPath).load(function(){
- $('.loading').fadeOut('fast');
- $('#largeImg').fadeIn('normal');
- });
- }
- };