SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Using a hover event to scroll a page in any direction?

    How can JavaScript be used to navigate a page's overflowed:hidden content when hovering over an anchor element?

    I plan on having content overflow in both X and Y directions inside my wrapper markup div. I'm going to hide the scroll-bar and try to leverage a more modern type of "hover-scroll method" of moving between locations using anchors and JavaScript (think of it as a tabletop perspective where the top, bottom, left and right margins would act as "hot spots" whereby when hovered upon, the scrolling effect would occur). The idea is pretty simple, but the implementation of it so far has been somewhat difficult...

    I'd feel safe in assuming that this can be done but would any of you know what the best route would be? Part of my problems in this is finding the right sources to springboard off of. I've seen a bunch of web pages out there with tutorials and so forth, but many have been spotty when trying to hit topics that pertain to this idea.

    I found a jQuery plugin called "Smooth Div Scroll" that has a perfect example of the type of scroll functionality I desire, but I'm a bit overwhelmed at all the black-box code being used for it (black-box for me, at least) . Besides that, it introduces reasons to be concerned about unnecessary amounts of code. Surely a vertical and horizontal "hover-scroll" system can be implemented without all that jQuery throughput... Right?

    Any suggestions to shine some light on this would be really appreciated.

  2. #2
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this fits the bill and it's jQuery-free.

    Always provide a way of restoring the scrollbars.

  3. #3
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Earlier this year I built something not dissimilar to what you're describing I think. I quickly ripped out the guts of it and placed it online so you can take a look at it: http://afterlight.com.au/lab/overflown/

    It uses the jQuery MapBox plugin to achieve the "overflow panning" effect. Take a peak through the main JS file and you should be able to glean what's happening. In this example, I have 4 buttons that you can press (and hold down) to scroll the area (or you can use the arrow keys), it would of course be trivial to turn the mousedown in to a mouseover to achieve what you're after.

    You can most certainly do it without jQuery, it would just be slightly more work. And as it often is, it's a question of how much time/effort/money is there available to build a bespoke solution vs. using jQuery + plugins and massaging them to do what you want.

    Let me know if there is anything really unclear about it, or if you want some more info :-)
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  4. #4
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Calvert, that is EXACTLY what I was hoping for. You sir, are a gentleman and a scholar. :.)

  5. #5
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    John, I appreciate your link there because that will help me with another project I have coming up soon pertaining to some RPG stuff I do. I went ahead and downloaded that page you provided to take a look at it later. Is there any way to make the idle activity's cursor (not sure how to describe it) capable of highlighting text?

  6. #6
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Wolf_22 View Post
    John, I appreciate your link there because that will help me with another project I have coming up soon pertaining to some RPG stuff I do. I went ahead and downloaded that page you provided to take a look at it later. Is there any way to make the idle activity's cursor (not sure how to describe it) capable of highlighting text?
    You should be able to do that without too much hassle. I've disabled the selecting because the app I built it for used a drag interface and no text on the front page. The MapBox plugin actually takes care of the panning, which can be disabled quite easily by setting the "pan" option to "false".

    Code:
    $viewport.mapbox({ 
        zoom: false, // does map zoom? 
        pan: false, // does map move side to side and up to down?
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  7. #7
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Calvert Tripesi View Post
    I think this fits the bill and it's jQuery-free.

    Always provide a way of restoring the scrollbars.
    Calvert, is there a way to make the second parameter leverage percentages?

    I.e. -
    Code:
    CursorDivScroll(divId,activeDepth,stepFactor)
    The layout of the page I'm using is elastic and I would like to continue using this kind of layout if possible. The problem is that the "activeDepth" parm seems to require pixels. What level of difficulty would it be to make it use percentages if one were to manually modify that code to support it?


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
  •