Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery animate() producing wild results
    primarykey
    data
    text
    <p>I'm pretty new to jQuery and I've been fooling around with its animate() but I've run into two problems. My code below is basically supposed to expand the characterwindow when the mouse is hovering over it, changing the text inside once it's expanded. Then characterwindow should retract back to it's original size when the mouse goes off the now larger version of it, changing the text as it starts to retract.</p> <p><strong>My problem</strong> is that this is just generally screwy as hell. If you just zoom your mouse in and out a few times it constantly expands and retracts for a bit without you doing anything, and the text flickers when you go in and out and doesn't even disappear before the retraction like it should.</p> <p>I tried using the callback parameter for the mouseover, but sometimes the text would show up before the animation actually finished.</p> <p>Is this a limitation of jQuery, JavaScript, my server, my client, or what? If there's a better/more efficient way to implement this I'd be grateful if you showed it.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;div id="characterwindow" style="width:80px;height:23px;border-radius:15px;"&gt; &lt;div id="characterwindowgraphic" style="border-radius:15px;background-color:#1C1C1C;height:23px;width:80px;"&gt; &lt;center&gt;&lt;p1 id="characterwindowtext" style="color:white;"&gt;Character&lt;/p1&gt;&lt;/center&gt; &lt;/div&gt;&lt;/div&gt; &lt;script&gt; $("#characterwindow").mouseover(function() { setTimeout(function(){$("#characterwindowtext").html("Character&lt;br&gt;&lt;br&gt;Name&lt;br&gt;Details");},500); $("#characterwindow").css({"width":"300px","height":"250px"}); $("#characterwindowgraphic").animate({ width:'300px', height:'250px' },500); }); $("#characterwindow").mouseleave(function() { $("#characterwindowtext").text("Character"); $("#characterwindow").css({"width":"80px","height":"23px"}); $("#characterwindowgraphic").animate({ width:'80px', height:'23px' },500); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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