youtube / spfjs

A lightweight JS framework for fast navigation and page updates from YouTube
https://youtube.github.io/spfjs/
MIT License
2.23k stars 147 forks source link

Document how SPF handles anchor links #378

Open nicksay opened 8 years ago

nicksay commented 8 years ago

The SPF documentation needs to describe how anchor links (aka hashes aka fragments, eg /path#frag) are handled.

For example, from https://groups.google.com/d/msg/spfjs/zhdS3GQJEiY/IkR6w9ZSBAAJ

Also, when navigating between two URLs that only differ by the hash, SPF won't make a request, just scroll the page (if possible).

Here's an example of what happens when clicking or going back across some links:

[load]     /foo
[click]    /foo  -->  /bar             (request /bar)
[click]    /bar  -->  /bar#target      (scroll to #target)
[click]    /bar#target  -->  /other    (request /other)
[back]     /other  -->  /bar#target    (request /bar, then scroll to #target)
[back]     /bar#target  --> /bar       (scroll to top)
[back]     /bar  -->  /foo             (request /foo)
wimleers commented 8 years ago

+1 — this is obvious to those who have implemented something like SPF (for example: Turbolinks or https://www.drupal.org/project/refreshless), but not to everyone. It's valuable to have this documented, to prevent confusion, help future maintainers and avoid having to repeat the same answers.