Fullpage.js: scroll event doesn't update window location hash

Created on 23 May 2014  路  7Comments  路  Source: alvarotrigo/fullPage.js

Right now the library does 2 things (which make total sense):

  1. When the user clicks on a link with a target as the href, the library recognizes the 'hashchange' event, and changes to the selected page.
  2. When the user scrolls on the screen, the library recognizes the scroll event and changes to the next page in the scroll direction.

However, when the user scrolls and the library changes the page, it does not update the window location hash. This means that if someone scrolls to the next page, they won't be able to deep link to that page. They will be able to deep link if they click on a link with a target as the href, but not scrolling.

Here's a user story if this helps:

  1. User visits website, first page is shown by default.
  2. User clicks on <a href="#page2">Page Two</a>, which changes the URL to http://example.com/#page2 and triggers the window.hashchange event.
  3. FullPage.js' listener on the window.hashchange event animates to the next page.
  4. User copies url to direct people to page2 and people who click on http://example.com/#page2 will successfully see the second page.

Not working story:

  1. User visits website, first page is shown by default.
  2. User scrolls on window with intention of visiting next page.
  3. FullPage.js' listener on window.scroll animates to the next page.
  4. User copies url (which is still http://example.com) with the intention of showing people the second page.
  5. People who click on the shared link will not see page 2, instead they will see the default first page.

Ref: #175. Is that clearer?

Most helpful comment

Should it work if I use data-anchor on sections instead of referencing them specifically on initialization?

All 7 comments

Not working story:

1 User visits website, first page is shown by default.
2 User scrolls on window with intention of visiting next page.
3 FullPage.js' listener on window.scroll animates to the next page.
4 User copies url (which is still http://example.com) with the intention of showing people the second page.
5 People who click on the shared link will not see page 2, instead they will see the default first page.

I don't know how are you able to reproduce it. The point 4 is wrong. The URL should be with an anchor link (#).

If you try it by using the demo page, you will see the URL hash changing every time you make any scroll with the mouse.
And that's not because of the window.scroll event, but because of the mousewheel one.

Even if you use autoScrolling:false the URL hash keep updating on scroll as you can see in this other example online. This time triggered by window.scroll.

Show me an example reproducing your problem. I really don't understand which is the trouble you are having.

We weren't using autoScrolling:false, but I re-looked at your demo code and not specifying the anchors fixed this issue. That's a very interesting behavior.

If I have some time I'd like to help you flush out more of the docs. The options aren't self-explanatory and the required options don't seem noted.

Anyway, thanks for being responsive to my questions!

not specifying the anchors fixed this issue

Anchors are required if you want them to work. What do you mean?

Sorry, specifying the anchors fixed the issue. The problem was we weren't specifying the anchors manually.

Should it work if I use data-anchor on sections instead of referencing them specifically on initialization?

Hello,

I realise this is an old one but I'm facing the same issue.
I've implemented fullPage as a Drupal 8 module. It's working fine except for the URL which is not updated. Neither on scroll for the sections nor using the arrows for the slides.
autoScrolling is on default value, hence true.
anchors are named using data-anchor

Regards,

@glouton if you believe it is a bug please open a new issue with an isolated reproduciton of it with the minimum amount of HTML code and no external CSS or JS to fullpage.js.

Was this page helpful?
0 / 5 - 0 ratings