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 in page link navigation with scrolling? #2

Closed
wad3inthewater opened this issue Oct 7, 2013 · 10 comments
Closed

Support in page link navigation with scrolling? #2

wad3inthewater opened this issue Oct 7, 2013 · 10 comments

Comments

@wad3inthewater
Copy link

I tried setting up some links for a single page style site with the jinvertscroll and it doesn't seem like the links are able to jump to the correct place on the page.

Is there something extra i have to do to make this work or is in-page linking not supported with the plugin by default?

@pixxelfactory
Copy link
Owner

Hi, thanks for your feedback, how does it behave in detail? Does it jump to the wrong position or does it not jump at all? How did you implement the links? Standard a-tags to the anchors or some custom jQuery animation?

@wad3inthewater
Copy link
Author

No animation, just standard anchor tags in an ul pointing to divs with ids. It doesn't jump to the link, instead it just pushes the tag down a bit each click no matter which link i click. So if i repeating click any given link i reach the bottom of the page.

I originally wanted to make it work with a smooth scrolling plugin but saw the issue and stripped it down to just regular a-tags and the problem still came up. I can send a link to the page I mocked up a bit later.

@pixxelfactory
Copy link
Owner

Yes, please send us a link, so we can look into the issue.

@wad3inthewater
Copy link
Author

Heres a link to a modified version of the example page you guys provide. If i place the content i want to navigate to with links inside a div that has the horizontal js applied to it, the links don't work correctly on the content. If I remove the class thats hooks the js in, then the nav works normally. Not sure if theres something I might not being doing, but thought this might be an issue with the plugin.

http://wadefuller.com/test/tester/

@johannalexander
Copy link

I've also tried adding normal anchor tags < a href="#about">About and linking it to < div id="about" style="width: 960px;left: 3800px;">About Us</ div> and it doesn't link up. Does it have something to do with it scrolling horizontally and not vertically.

By the way, the plugin is awesome! Very intuitive.

@pixxelfactory
Copy link
Owner

Hi, we gave a look at the example you provided and the issue you have.
To link at parts of the page, you have to create some anchor tags and position them vertically, for your example the code would be:

Html (add this after the nav-element):

Stylesheet:
.anchors
{
position: relative;
}

.anchors #100
{
    position: absolute;
    top: 0;
}

.anchors #200
{
    position: absolute;
    top: 850px;
}

.anchors #300
{
    position: absolute;
    top: 1700px;
}

.anchors #400
{
    position: absolute;
    top: 2550px;
}

At the moment you need to create these elements manually,
since the plugin does not auto-generate this markup currently.

Let me know if it works, so i can close the issue.

Best regards
Pixxelfactory

@johannalexander
Copy link

It looks like it works! The anchors are grouped below the nav and above the content separately. Thanks!

@Blackcoreweb
Copy link

Hello,
Is the example on the specific page working?
I have exactly the same issue. My sample page is http://www.beta.dart.com.cy/mf/

Can you please advise how to make anchors work?

Thanks in advance,

@pixxelfactory
Copy link
Owner

Hi,

as stated above, you need to create a container div, wich holds the invisible anchors, for your example this would be:

<div class="anchors">
<a name="home" id="home"></a>
<a name="products" id="products"></a>
<a name="health" id="health"></a>
<a name="wheretobuy" id="wheretobuy"></a>
<a name="contact" id="contact"></a>
</div>

Then, exchange your current links with one that link to the actual anchors like this:
<div class="menu-holder">
<a class="menu-home" href="#home"></a>
<a class="menu-products" href="#products"></a>
<a class="menu-health" href="#health"></a>
<a class="menu-wheretobuy" href="#wheretobuy"></a>
<a class="menu-contact" href="#contact"></a>
</div>

Add the anchor positioning to your styles:
.anchors a
{
display: block;
position: absolute;
}

#home
{
top: 1800px;
}

#products
{
top: 3650px;
}

#health
{
top: 5250px;
}

#wheretobuy
{
top: 6900px;
}

#contact
{
top: 7500px;
}

And finally, change your current menu scrolling script with this one:
$('.nav a').on('click', function(e) {
e.preventDefault();
var top = $($(this).attr('href')).position().top;
$('html, body').animate({scrollTop: top+'px'}, 1200);
});

That's it
Best regards
pixxelfactory

@janbaykara
Copy link

Is there a simple way to calculate (depending on screen, element sizes etc) the TOP value needed for these links? I've some automatically generated content and can't figure out how to translate % scroll to it.

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

5 participants