Search and Top Navigation
#7455 closed bug (notabug)
Opened June 07, 2011 05:01AM UTC
Closed June 07, 2011 11:58AM UTC
bug with animate using vals from array?
Reported by: | bazz | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.effects.core | Version: | 1.8.13 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hi there,
I'm testing an un-live potential web design of a book/library with bookshelf(menu), page turning, etc (all animated with jquery). And with a hidden chest inside a book that opens when clicked, 3-15'sh images/links pop-out and slowly rotate in a pseudo-circle. I'm echoing the coordinates for each circle-point to move to - confirming they are calculated correctly - yet the first image/link does not follow the "y" coordinate its given (and moves around somewhat randomly). Therefore I believe it is a bug with .animate(). All other images/links rotate as expected. I'm hardly a prof programmer but I don't think I have any logic errors, closing loops properly, etc.
1st time posting here so hopefully my code snippet will paste in as follows... (any ideas, thoughts or confirming this as a bug would be appreciated):
/* chest */ var coords = new Array(); var use_alt = 0; function getCirclePoints(centerX, centerY, radius, segments){ var totalPoints = new Array(); for(var i = 0; i < segments; i++){ /* (adjusting plots for positioning) */ x = Math.round(centerX+radius*Math.sin(i*2*Math.PI/segments))-60; y = Math.round(centerY+radius*Math.cos(i*2*Math.PI/segments))-70; totalPoints.push({'x':x,'y':y}); } return totalPoints; } /* reindex array for subsequent positions */ function reindex_coords() { if (use_alt == 1) { var my_count = coords.length; } else { var my_count = $("#content #chest_icons a").length; } for (i=2; i <= my_count; i++) { my_x = coords[0]["x"]; my_y = coords[0]["y"]; coords.shift(); coords.push({'x':my_x,'y':my_y}); }; icons_rotation(); } function icons_rotation() { /* test if rotation needs to stop */ if ($("#content #chest_icons").css("z-index") == "2000") { /* variable speed for rotation */ ispeed = $("#content #chest_icons a").length; ispeed = Math.round(80000/ispeed); if (ispeed > 20000) {ispeed = 20000;} if (ispeed < 10000) {ispeed = 10000;} ispeed = 4000; //for quicker testing /* set new position */ var i = 0; $("#content #chest_icons a").each(function() { $(this).stop(true, false).animate({"top" : coords[i]["y"], "left" : coords[i]["x"]}, ispeed, "linear"); /* debug */ var this_id = $(this).find("img").attr("alt"); $("#debug").append(i+'x='+coords[i]["x"]+', '+i+'y='+coords[i]["y"]+', '+this_id+'<br />'); if (use_alt == 1) { i++; }; i++; }); /* fake delay b4 getting next coords */ var temp_speed = ispeed/* + 100*/; $("#chest_icons").stop(true, false).animate({"top" : "0"}, temp_speed, function() { reindex_coords(); }); }; } $("#content #chest").live("click", function(event) { if (test_anim == true) { return false; } else { test_anim = true; $("#content #chest_icons").css("z-index", "2000"); $("#content #chest_closed").stop(true, false).animate({"opacity" : "0"}, 1000); $("#content #chest_open").stop(true, false).animate({"opacity" : "1"}, 1000, function() { var img_count = 0; img_count = $("#content #chest_icons a").length; var my_radius = 25 * img_count; if ( my_radius > 230 ) { my_radius = 230; }; if ( my_radius < 140 ) { my_radius = 140; }; coords.length = 0; if (img_count > 2 && img_count < 10) { use_alt = 1; var dbl_count = (img_count * 2); coords = getCirclePoints(220, 220, my_radius, dbl_count); } else { use_alt = 0; coords = getCirclePoints(220, 220, my_radius, img_count); }; var i = 0; /* set initial position */ $("#content #chest_icons a").each(function() { $(this).stop(true, false).animate({"top" : coords[i]["y"], "left" : coords[i]["x"]}, 1000); if (use_alt == 1) { i++; }; i++; }); /* fake delay b4 calling function (slightly longer to ensure correct positioning */ if (img_count > 2) { $("#chest_icons").animate({"left" : "0"}, 1100, function() { reindex_coords(); }); }; }); test_anim = false; }; }); $("#content #chest_icons a").live("click", function(event) { window.location = $(this).attr("href"); return false; }); $("#content #chest_icons").live("click", function(event) { cleanup_chest_page(); });
Attachments (0)
Change History (1)
Changed June 07, 2011 11:58AM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Your code isn't using anything from jQuery UI. Please report this in the jQuery bug tracker. You'll also want to reduce the code quite a bit to prove there's a bug, we won't dig through all of your code to verify your logic if you're not sure that the bug isn't in your code.