Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: [DHTML] Keep In View (Float Menu Replacement)

  1. #1
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default [DHTML] Keep In View (Float Menu Replacement)

    1) CODE TITLE:
    Keep In View

    2) AUTHOR NAME/NOTES:
    Roy Whittle
    This script will keep almost any html element in view even if the user scrolls the browser window.

    It is a re-write of the float menu code. Now we (js coders) don't have to consider netscape 4 it makes the code a lot simpler. It also solves problems that users have asked for. How do align center, how do I keep it in the left/right of a table column, how can I make it not scroll untill it is going off the screen.

    I have tested the code in various browers, with various doctype settings, floating various HTML elements(table, td, tr, img, div, span) but due to the possible combinations I cannot test all. You could simply state that all "Keep In View" elements must be in div's.

    I have coded it so all the user has to do is give the element an "id" of "jsfx_float<x>" where x=0 to 3. The code can easily be changed to let the user specify the "id" of the element that needs to float.

    3) DESCRIPTION:
    Using this script you can keep any html element in view when the user scrolls the browser window. Simply give the element an id of jsfx_float0, jsfx_float1, jsfx_float2, jsfx_float3, then cut and paste the script just before the closing body tag </body>

    4) URL TO CODE:
    Keep In View

    P.S.
    If javascript is disabled then the page should layout as normal but the elelemnts will simply not float.
    Last edited by RoyW; 08-02-2006 at 03:24 AM. Reason: Add "PS"

  2. #2
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Excellent script, beautiful clean coding - very impressive and helpful~!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It is nice looking. However, you should probably round off your math in one or more spots to be kind to browsers, and cpu's.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's kinda jerky, but I suppose that is to be expected, and also extreme in the example with so much moving around.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jan 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is a cool script, it already starts at the position you want it but I wonder how can you limit the movement of the floating elements to a specific area (like a table) so it doesn't go all the way til the end?. Anyone? Thanks.

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Wow, old thread bump got me confused there for a moment lol.

  7. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Clever scripting.
    One general question, though. Why would people use 'float' instead of 'position:fixed'? ('Fixed' is never jerky).

    Arie Molendijk.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by molendijk View Post
    Clever scripting.
    One general question, though. Why would people use 'float' instead of 'position:fixed'? ('Fixed' is never jerky).

    Arie Molendijk.
    I know that one, fixed isn't supported in IE 6, and because many people like the way that a floating object attracts more attention and looks more graceful than a fixed one. The trick is to get the floating action smooth. Generally this is done by decreasing the increment of positional change as the object approaches its desired location.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    But 'fixed' can easily be fixed for IE6. And if the floating istn't smooth, it will disturb rather than attract people.

    Arie M.

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I've never seen any fix for 'fixed' in IE 6 that wouldn't breakdown under certain layouts, and/or styles, and/or scripts.

    I won't argue the point about floating being no good if it is jerky, because I never said that it was good if jerky. But that is a separate issue.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •