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

Scroll position #2

Open
nathobson opened this issue Jan 13, 2015 · 6 comments
Open

Scroll position #2

nathobson opened this issue Jan 13, 2015 · 6 comments

Comments

@nathobson
Copy link

Hi.

Firstly, thanks for the great plugin. I'm using it in a project at the moment and it's all working great. Apart from one thing...

On the page where I'm using Hash Tabs, whenever I access the page, I'm automatically scrolled down to the tabs section. I can see that this is not the case on the demo page. This is a problem as the tabs are halfway down the page. I can spoof this a bit by using smoothScroll then initialising a tab ID that doesn't exist:

$(".hashtabs").hashTabs({
smoothScroll: {
enabled: true,
initialTabId: "dummy"
}
});

The problem with that is that it loads down at the tabs, then shoots up to the top of the page again, pretty jolting!

I've made a codepen with an example of being scrolled down: http://codepen.io/anon/pen/rayVpo. You'll see there's a nav and footer with the tabs in the middle of the page but you'll land of the tabs.

@srsgores
Copy link
Owner

@nathobson, sorry for the delay on this. Have you resolved the issue? Are you able to replicate the same problem without using smoothScroll?

@nathobson
Copy link
Author

No problem, thanks for the reply.

No, I haven't been able to resolve this unfortunately. I was thinking it might be due to my set up as your demo page seems to work perfectly but as you can see in the codepen I posted above, that's about as basic an implementation as I can put together and I still can replicate the issue. On the codepen I haven't used smoothscroll – you can see the JS that calls hashtabs at the bottom of the JS panel.

@srsgores
Copy link
Owner

@nathobson, I'll have a look when I get the chance. Hopefully, you'll hear from me shortly regarding this.

@lozov
Copy link

lozov commented Feb 6, 2015

Hi there!
I have the same problem in Chrome. In the FireFox its ok.

@srsgores
Copy link
Owner

Ok, sorry again for the delay. The reason this is happening has very little to do with the script, but actually browser behaviour. When window.location.hash is changed to a hash in the current document, the browser will "scroll" to that element.

So I'm going to fix it with this fix.

@srsgores
Copy link
Owner

Further update: since we're exclusively using the history API, I don't think it is what I described earlier. Perhaps it's the triggering of the click event on the tabs?

srsgores added a commit that referenced this issue May 16, 2016
#5 - Fix self/this typo causing hashChanges to fail
Update dist
Bump version
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