mysterious trouble with jQuery .animate() with step option -
not long ago have deal easy work: animate 2 elements together, moving second 1 according first element moving. not problem: .animate() step option makes well, , made work. troubles began when attempted inject code test-page real site. clarified main part of .animate() executed, function pointed step option not executed. reason of linking document script called interface.js (http://interface.eyecon.ro) it's used creating elements, fish-eye panel in case. link (script type="text/javascript" src="..." etc) script "kills" animation (second part of it, step function), without calling its(interface.js) functions. illustrate trouble i've prepared little example: 2 red boxes positioned in opposite corners of rectangle, clicking on them starts animation, swapping places.
html:
<div id="container"> <div id="div1" class="box"></div> <div id="div2" class="box"></div> </div>
css: (sorry ugly selectorless "css"-syntax, that's first post, css correct in real file)
container-id-selector { width: 500px; height: 100px; position: relative; } div1-id-selector { background-color: red; width: 50px; height: 50px; position: absolute; left: 0px; } div2-id-selector { background-color: red; width: 50px; height: 50px; position: absolute; top: 50px; right: 0px; } box-class-selector { cursor: pointer; }
javascript:
$(document).ready(function() { $(".box").click(function(){ $("#div1").animate({ left: 450}, { duration: 2000, step: function(now, fx){ $("#div2").css("left", 450 - now); } }); }); });
this example works perfectly, if add 1 line :
<script type="text/javascript" src="interface.js"></script>
kills animation:( first box moving left right, second not moving @ all, because function pointed step not calling. including file (interface.js), not calling functions. know reason of such problem? want know internal causes of such strange behavior, , ways work-around it. ideas?:) lot!
p.s. there non-minimized version of script on developer's site, js&jquery skills poor detail investigation. lot again, , sorry many letters, i'm confused trouble:(
Comments
Post a Comment