Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Better way of achieving this?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #146308
    alexemorris
    Participant

    I’m just finishing a website off for a client. Its almost finished, just need to work on some backwards compatibility and the menus are probably littered with grammatical/spelling errors. I apologise in advance. http://greygoosegilmorton.co.uk (domain not fully propagated yet, if it doesn’t say AEM Design on the bottom of the page, its the wrong site)

    I’m just not very proud of my work with the image scroller. It seems a bit hacky at the moment. Whats the best way of achieving this? Below is my current code..

    var images = []
    var imagewidth = $('#images').find('li').width();
    $('#images').find('li').each(function(i) {
        images[i] = '
  • ' + $(this).html() +'
  • ' }) var imagelength = images.length var total = 1 function animateslider() { $('#images').stop().animate({'marginLeft' : -(total*imagewidth)},8000,'linear',function() { total = total + 1 $('.slider').append(images[(total) % imagelength]) if (total > 5) { $('.slider').find('li').eq(total-5).empty() } if (total > 60) { } else { animateslider() } }) }

    It stops after 60 to avoid using too much memory… The problem is sometimes it bugs out and you start seeing the process on the right of the screen and the white space catches up until you can’t see any images any more. I feel there is a much more efficient way which I’m missing.

    #146409
    TheDoc
    Member

    Just a heads up: this is near impossible to read: http://cl.ly/image/2H0K0a3q2B2q

    Right now there is a console error, so I’m unable to really test out the slider: Uncaught SyntaxError: Unexpected token += slider.js:25

    #146410
    alexemorris
    Participant

    Oh wow, that is odd. I changed the font over on a non retina display and forgot to change the weight. I’ll fix it now, thanks for that!

    I’ve been fixing backwards compatibility on IE 7 today must have missed that.

    #146412
    alexemorris
    Participant

    Ok, so I’ve fixed the console error. However now its got a strange problem where it animates it far too much and then it works okay not ideal though

    #146414
    alexemorris
    Participant

    No worries, I have just found this tutorial which I’m going to take some inspiration from.

    http://designshack.net/articles/css/infinitephotobanner/

    I’ll have it static on non CSS3 browsers I think

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.