SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    A couple of questions

    Hi,

    First off, I'd like to create my own menus (not use someone else's script) but what I really want is the effect of the menu sliding out from the original link and then unrolling down. A few people have told me this would be easier in Flash but I don't want to use it for my own reasons

    I know how I would do it and everything (document.getElementByName('blah').style.width = document.getElementByName('blah').style.width + 5) but I don't know how to do a loop that will take enough time to see the effect smoothly.

    While I was typing I forgot my second question so it's down to one

    Ta for the help

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like

    function moveIt()
    {
    var obj = document.getElementById('blah');
    // do something...

    if(!done) setTimeout('moveIt()', 50);
    }

  3. #3
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since animation is time critical, you need to optimize your code as much as possible, and then regulate the speed with setTimeout() as Jofa suggests.

    Read up with a relevant search on Google (e.g. "javascript optimization").
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For example:
    Code:
    document.getElementById('blah').style.width = document.getElementById('blah').style.width + 5
    document.getElementById('blah').style.height = document.getElementById('blah').style.height + 5
    could be optimized to
    Code:
    var obj_style = document.getElementById('blah').style;
    obj_style.width += 5;
    obj_style.height += 5;
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Thanks for the help guys but my computer is stuffed due to storm damage but hopefully I should get it back soon


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
  •