Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for on page navigation / scroll to / anchors #36

Open
deanbot opened this issue Oct 18, 2014 · 2 comments
Open

support for on page navigation / scroll to / anchors #36

deanbot opened this issue Oct 18, 2014 · 2 comments

Comments

@deanbot
Copy link

deanbot commented Oct 18, 2014

Noticing the following issues with named anchors (i.e. #terminology) within scrollbox content:

  1. navigating manually to a url that includes a location (i.e. mysite.com/my-page#myloc):
    • content is in the correct location
    • thumb is not in the correct location. it's set to 0
  2. clicking a link on a page which links to a location on the same page:
    • nothing happens other than the url updating
@wieringen
Copy link
Owner

I think this can be done by extending tinyscrollbar using the current methods. Not sure about how I feel about implementing this by default.

@deanbot
Copy link
Author

deanbot commented Dec 16, 2014

Hmm. To implement I converted # signs to query strings - grabbing the value and navigating using the following method on page load. Linking to areas on the same page was accomplished by adding a special class to links and locations - navigating on click. I could not get # signs to work.

Linking to an area on the same page required using position() where handling the location on page load required offset.

navigateToScrollLocation = function(loc, usePosition) {
    if(!loc)
      return;

    // if clicking within the content use position instead of offset
    var l = $('.sloc-'+loc),
      lo = l ? (usePosition ? l.position() : l.offset() ) : false,
      lp = lo ? lo.top : false,
      lf = usePosition ? lp + 20 : lp - 150;

    if(lo)
      _this.scrollbarOptions.update(lf);
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants