Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are several problems here. First <code>.load</code> is not a reliable way to detect image loading. Some browsers, when the image is cached, wont fire a load event, so the script will fail. You need to use a plugin like <code>waitForImages</code> or <code>imageLoaded</code>.</p> <p><a href="https://github.com/alexanderdickson/waitForImages" rel="nofollow">https://github.com/alexanderdickson/waitForImages</a> I recommend this one.</p> <p>Also <code>.stop()</code> will work fine for your needs, if it seems to cancel fades in some instances, try <code>.stop(true, true)</code>, it should animate just fine, even with loading data and multiple fades. You may need to tune it so that the stop command only is placed on the last fade to occur.</p> <p>also you are making a ton of jQuery objects when you only need one. Limiting it to one object will make your script substantially more efficient.</p> <pre><code>var previewBox = $('.previewBox'); </code></pre> <p>Then you can use that one everywhere:</p> <pre><code>previewBox.mouseenter(function() { if(hov === false) { hov = true; previewBox.stop().fadeOut(function(){ previewBox.imagesLoaded(function... </code></pre> <p>In your case with the multiple instances using a class, you need to isolate your events from one another. You can do this with <code>.each</code></p> <pre><code>$('.previewBox').each(function(){ var previewBox = $(this); previewBox.mouseenter(function(){ .... </code></pre> <p>By wrapping all your current logic in a <code>.each</code> you will avoid interaction of events between elements. In this way the events <code>mouseenter mouseleave</code> and the attached logic will bind isolated to each instance of an element with that class, instead of binding to all elements of that class.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload