Skip to content

Commit

Permalink
Made enhancements to the javascript for the image preview to where it…
Browse files Browse the repository at this point in the history
… will cancel immediately when the mouse is no longer over it.
  • Loading branch information
amereservant committed Jun 27, 2011
1 parent ed051c8 commit 7927a22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions js/sitejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author David Miles <david@thatchurch.com>
* @package Flickerd
* @link https://github.com/amereservant/FlickerdTheme
* @version 1.0.2
* @version 1.0.2a
*/
(function($) {
/**
Expand Down Expand Up @@ -107,21 +107,33 @@

elem.after('<div class="image-overlay-loader loaderbg" style="width:'+ width +'px;height:'+height+'px">'+
'<img src="'+orgsrc+'" id="overlayImg" style="display:none" /></div>');

var img = new Image();

$('.image-overlay-loader').bind('mouseleave', function() {
$(this).remove();
img = null;
});

$(img).load(function() {
$('#overlayImg').attr('src', src);
$('#overlayImg').fadeIn();
$('#overlayImg').fadeIn('normal', function() {
if(img === null) {
$('.image-overlay-loader').remove();
$('#overlayImg').remove();
}
});
if(img === null) return false;
$('.image-overlay-loader').removeClass('loaderbg').css({'width':img.width, 'height':img.height});
}).attr('src', src);

$('#overlayImg').bind('mouseleave', function() {
$('.image-overlay-loader').remove();
});

}, flickerdPreviewDelay);
elem.bind('mouseleave', function() {
window.clearTimeout(timeoutID);
});
$('#overlayImg').bind('mouseleave', function() {
window.clearTimeout(timeoutID);
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion js/sitejs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7927a22

Please sign in to comment.