Note that there are some explanatory texts on larger screens.

plurals
  1. POScriptaculous Callback Irregularities with Move Effect
    primarykey
    data
    text
    <p>I would like to bump a menu item out 5px on mouseover and have it return to its original position using Scriptaculous. I am using the afterFinish callback to ensure that the bump-out Move effect is completed before the bump-back-in Move effect runs.</p> <p>The problem is that the item doesn't return to its original position if you quickly mouseover and mouseout more than once. The more you mouseover-and-out, the more it's off. I thought this is what the afterFinish callback was supposed to prevent. It seems to work correctly with the Morph effect, and it's supposed to work with all Scriptaculous effects, as stated below:</p> <p><a href="https://stackoverflow.com/questions/2330809/javascript-scriptaculous-effect-callback-function">Javascript - Scriptaculous - Effect Callback function</a></p> <p>I've tried using effects queues, same result, and spent several hours scouring various forums to help me understand this.</p> <p>Here is the Morph example that works correctly:</p> <pre><code>&lt;SCRIPT&gt; function morphMe(obj) { new Effect.Morph($(obj), { style: { height: '200px', width: '200px'}, afterFinish: function(){ new Effect.Morph($(obj), { style: { height: '20px', width: '200px'}}); } }) } &lt;/SCRIPT&gt; &lt;div id="bumptest" class="leftnav" style="position: absolute; left: 100px; width: 200px; border: 1px solid green" onmouseover="morphme(this);"&gt;Morph Me&lt;/div&gt; </code></pre> <p>Here's the Move example that doesn't work as expected on quick mouseover and outs. Perhaps I need use setTimeout but I don't understand why this should be necessary.</p> <pre><code>&lt;SCRIPT&gt; function OnFinish(obj){ new Effect.Move(obj.element.id, {x: -5, y: 0, duration: .4}); } function bumpOut(myObject){ new Effect.Move(myObject, { x: 5, y: 0, duration: 0.4, afterFinish: OnFinish, }); } &lt;/SCRIPT&gt; &lt;div id="bumptest" class="leftnav" style="position: absolute; left: 100px; width: 200px; border: 1px solid green" onmouseover="bumpOut(this);"&gt;Bump me right and then back&lt;/div&gt; </code></pre> <p>Any help, maybe even a mod using setTimeout or a pointer to a solid script that already does this, greatly appreciated.</p> <p>Thanks,</p> <p>motorhobo</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. 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