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

Offset is ignored when accessing section directly #21

Open
adamstrojil opened this issue Nov 9, 2015 · 6 comments
Open

Offset is ignored when accessing section directly #21

adamstrojil opened this issue Nov 9, 2015 · 6 comments

Comments

@adamstrojil
Copy link

Hi Chris,
the browser seems to ignore offset when I'm accessing to certain section directly via link or URL. When I'm using navigation menu for this, the offset works fine. I've tried same thing using your live demo and get the same results.

For exapmle: When I click on Section 2, it navigates me correctly to a section 2 + offset, but when I enter the address manually (http://chriswojcik.net/demos/single-page-nav/#section2) and press enter, it navigates me to the section 2 as well, but in this case without offset.

Is there any solution, how to get correct position in both cases?

@abdulrazakshaikh
Copy link

my navigation is set to top of section how can i give the offset to this jquery below

        $('#nav').singlePageNav({
            offset: $('#nav').outerHeight(),
            speed:2000,
            filter: ':not(.external)',
            updateHash: true,
            beforeStart: function() {
                console.log('begin scrolling');
            },
            onComplete: function() {
                console.log('done scrolling');
            }
        });

@abdulrazakshaikh
Copy link

samples
attached is the samples images

@adamstrojil
Copy link
Author

Hi 89abdul, what you have in your code means that the offset is equal to the height of an element with id 'nav'. Check if you have correct id for navigation in your HTML file ;) Or you can set offset manually in pixels. e.g. offset:200,

@abdulrazakshaikh
Copy link

nice its working
thanks adamstrojil

@JonCatmull
Copy link

This is simply not handled by this plugin (only handles clicks), the reason it works (minus the offset issue) is because that is a default browser behaviour to try and match whatever is after the # to an id in the document. If i have time I will fix and submit pull request.

@JonCatmull
Copy link

JonCatmull commented May 2, 2016

I have submitted a pull request in which I have fixed this as best I can. Tricky issue as browsers do not allow preventing of the automatic behaviour.
https://github.com/JonCatmull/single-page-nav

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

3 participants