SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image Rotation Problem - Help Needed

    I have this image rotate script where I upload images then I can rotate them through a Javascript script. The script works perfectly with few images but messes up with a lot of images. When there are a lot of images, if I click to rotate on image, it actually rotates another image. I ran this by someone else and he said "that's probably because the array containing the image names is out of order".

    Here is the code:
    Code:
    function step_2_rotate(o_src)
    {
        var i_event_row;
        if (o_src.id.match(/(\d+)$/)) {        
            i_event_row = Number(RegExp.$1);
            var i_angle = o_src.id.indexOf('left') >= 0 ? 3 : 1;
            
            var row_this = -1;
            for (i = 0; i < o_files_data.length && (row_this < 0); i++) {
                if (o_files_data[i].index == i_event_row) {
                    o_files_data[i].angle = (Number(o_files_data[i].angle) + i_angle) % 4;
                    row_this = i;
                }               
            }        
            step_2_draw_table();        
        }
    }
    Thanks,
    Matt

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Where is o_files_data.length defined? This might also work:

    Code:
    function setAngle(element, angle)
    {
       element.angle = angle;
    }
    
    function step_2_rotate(o_src)
    {
        var i_event_row;
        if (o_src.id.match(/(\d+)$/)) {        
            i_event_row = Number(RegExp.$1);
            var i_angle = o_src.id.indexOf('left') >= 0 ? 3 : 1;
            
            var row_this = -1;
            for (i = 0; i < o_files_data.length && (row_this < 0); i++) {
                if (o_files_data[i].index == i_event_row) {
                    setAngle(o_files_data[i],(Number(o_files_data[i].angle) + i_angle) % 4);
                    row_this = i;
                }               
            }        
            step_2_draw_table();        
        }
    }

  3. #3
    SitePoint Enthusiast ada80ro's Avatar
    Join Date
    Apr 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I think you should post an example because it's not very clear how the script works.

  4. #4
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My site is http://www.gigmax.com. If you want to see the problem yourself, just login as username account2 and password account2 and go to the Create Album tab in the My Gigmax section. After you do that, go ahead and select like 20+ images (of any size) then Upload them. Once you do that, you will see what I mean on the next screen when you try to rotate them.


    chris fuel:
    Code:
    var s_ga_album_title = '';
    var s_ga_album_description = '';
    var o_ga_current_wizard_div = null;
    var o_files_data = null;
    var o_files_dir = null;
    var f_nice_upload_no_status = true;
    var o_existing_files = [];
    Edit: That code did not work.

    ada80ro: If I upload a few images at once, then try to rotate each of them separately (which is what my script does), it works fine. When I click the rotate button, which triggers the above script, they rotate 90 degrees. However, when I upload like 20+ images and try to rotate one of them for some reason, it rotates a DIFFERENT image, not the one it is supposed to.

    Hope that helps,
    Matt

  5. #5
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Again, the problem is somewhere in the array code there.

    Matt

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Location
    London, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't get it either. Either construct an easier extraction of the code to help you with or consider simplifying your code. Be verbose and then you can Perlify it after again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •