Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multiple function calls from a single js file

    i have 4 images that expand onMouseOver and shrink onMouseOut

    <script src = 'js/size.js'>

    <div id = 'img1' onMouseOver = \"expand(this.id)\" onMouseOut = \"shrink(this.id)\">
    <img src = ...>
    </div>
    <div id = 'img2' onMouseOver = \"expand(this.id)\" onMouseOut = \"shrink(this.id)\">
    <img src = ...>
    </div>

    etc...

    question: when i quickly move the mouse from one image to the other shouldn't i see one expand and one shrink simultaneously?
    i am currently seeing one shrink, then the other expand after.
    on occasion the shrink is skipped and the next image is expanded right away.

  • #2
    Regular Coder
    Join Date
    Jun 2007
    Location
    USA
    Posts
    527
    Thanks
    26
    Thanked 74 Times in 72 Posts
    Javascript is a single threaded language, meaning that it can only do one thing at a time. So in your case, the expand function has to finish before the shrink function takes place. The easiest way to create your desired effect probably is to use a sequence of window.setTimeout()'s.

    Show your source code (js and html) please so we can help you better.
    Last edited by Trinithis; 12-11-2007 at 08:23 PM. Reason: clarification


  •  

    Posting Permissions

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