/    Sign up×
Community /Pin to ProfileBookmark

scrollbar position questions.

  • single page layout
    -fixed div header with links to page sections
    -fancy jquery (or some such library) smooth scrolling effect.

  • when the page scrolls to a section the link image (or flash movie) is going to depict that with a “you are visiting this section” state of being.

  • if the visitor scrolls by hand instead of clicking a link I need the link images in the header to change automatically to show where the user is.
  • my question:

    Ideally I would like to execute code when a specific anchor is within the top 250 pixels of the page. Is this possible?
    this is probably a step in the right direction: [url]http://mattkruse.com/javascript/anchorposition/source.html[/url]

    So something like this:
    Listen for the Y coordinates of #anchor1

    if thing.as3 was not the last thing loaded
    + y coordinates = 0-300 (anything between 0 and 300)
    load thing.as3 file and apply it to the movie.
    (or control MC from javascript)

    Else:
    load otherthing.as3 file and apply it to the movie.
    (or control MC from javascript)

    otherwise how do I achieve something close?

    to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @pixeltarianauthorFeb 05.2010 — after studying a bit. And utilizing prototype.js This is as close as I can come to achieving what I want. it's not real or functional or anything, but it's perhaps a better description of what I want to do:


    observe element viewportOffset

    if {

    element viewportOffset (y>=300 && y<=0);

    }

    then {apply file1.as3 to myFlashMovie.swf}

    for "then" any old thing will do. I can figure out how to control flash with javascript later. I'd settle for alert("it worked!"); at this point.

    if someone gets what I'm trying to do and wants me to beam with joy... I'd be elated if someone could explain how to make this idea real.
    Copy linkTweet thisAlerts:
    @harrierdhFeb 05.2010 — You can do what you want. It's late on friday I can't help you much more. Here are two links that might get you going.

    http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html

    http://www.eggheadcafe.com/community/aspnet/3/10017682/catch-a-scrolling-event-i.aspx
    ×

    Success!

    Help @pixeltarian spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...