Skip to content

Instantly share code, notes, and snippets.

@ucarion
Last active December 19, 2015 10:39
Show Gist options
  • Save ucarion/5942011 to your computer and use it in GitHub Desktop.
Save ucarion/5942011 to your computer and use it in GitHub Desktop.
Fix mouseenter / mouseexit bug
function itemOut(event) {
var to = event.relatedTarget;
var from = event.currentTarget;
// Get the first parent of from and to that match the selector ".isotope-item";
// if parents() returns undefined, then simply return from / to.
var parentFrom = $(from).parents(".isotope-item")[0] || from;
var parentTo = $(to).parents(".isotope-item")[0] || to;
// if the two elements are part of the same .isotope-item, then do not do any animation (this avoids shutter effects).
if (!touchM && !mobileM && !$(this).hasClass('noHover') && parentFrom !== parentTo) {
var $this = $(this);
$(this).children('img').stop().animate({'opacity': .7, 'marginTop': 0}, 200, 'easeOutQuad');
$(this).children('span.folioPlus').stop().animate({'opacity': 0, 'bottom': -53}, 200, 'easeOutQuad');
$(this).children('div.folioTextHolder').stop().animate({'height': 0, 'bottom': 0}, 200, 'easeOutQuad');
$(this).find('div.folioText').stop().animate({'opacity': 0, 'top': -150}, 200, 'easeOutQuad');
$(this).children('span.folioShadow').stop().animate({'opacity': 0, 'marginTop': 0, 'height': '0'}, 300, 'easeOutQuad', function(){
$this.css('zIndex', 1);
});
}
}
function itemOver(event) {
var to = event.relatedTarget;
var from = event.currentTarget;
// Get the first parent of from and to that match the selector ".isotope-item";
// if parents() returns undefined, then simply return from / to.
var parentFrom = $(from).parents(".isotope-item")[0] || from;
var parentTo = $(to).parents(".isotope-item")[0] || to;
// if the two elements are part of the same .isotope-item, then do not do any animation (this avoids shutter effects).
if (!touchM && !mobileM && !$(this).hasClass('noHover') && parentFrom !== parentTo) {
$(this).css('zIndex', ++zI);
$(this).children('img.folioThumb').stop().animate({'opacity': 1, 'marginTop': -70}, 300, 'easeOutQuad');
$(this).children('span.folioPlus').stop().animate({'opacity': 1, 'bottom': iH/2-30}, 300, 'easeOutQuad');
$(this).children('span.folioShadow').stop().animate({'opacity': 1, 'marginTop': -70, 'height': iH+140}, 300, 'easeOutQuad');
$(this).children('div.folioTextHolder').stop().animate({'height': iH/2+itemPadding, 'bottom': -70}, 300, 'easeOutQuad');
$(this).find('div.folioText').stop().animate({'opacity': 1, 'top': 0}, 350, 'easeOutSine');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment