Re: Is there a way to autoscroll the toc from the content in HTML

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/Is-there-a-way-to-autoscroll-the-toc-from-the-content-in-HTML-tp4525p4530.html

Antoine,

This feature is certainly achievable and something I agree would make navigating large documents much easier.

Implementing this feature involves adding some JavaScript to the page. You can add the necessary JavaScript right now using a docinfo file (or docinfo extension). This is particularly feasible since all the sections have IDs by default and the entries in the TOC refer to those IDs. The only thing left to do is coordinate the scroll position to one of the entries by toggling a CSS class.

The common name for this feature is "scroll spy". There are numerous libraries available that implement it. The one from Foundation is called Magellen {1}. If we decided to integrate this feature into core, we'll probably write something custom.

I think the next step is to implement a prototype which we can put into the extensions lab (as a docinfo extension). We can refine it there, then sort out the best way to integrate it into core, if we decide it should go there.

Here are a couple of examples for reference:

https://docs.mulesoft.com/mule-fundamentals/v/3.7/build-a-hello-world-application
http://afeld.github.io/bootstrap-toc/
http://arquillian.org/guides/getting_started/

If anyone has other reference examples, I encourage you to post them.

-Dan

:1: http://foundation.zurb.com/sites/docs/v/5.5.3/components/magellan.html

On Wed, Mar 16, 2016 at 3:06 AM, Antoine Sabot-Durand [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

I have a rather large document and I'd like to provide links to some sections.

To ease life of readers, I'd like to see the TOC scrolled to the matching section (from fragment id in URL), so he can see the related topics in the document and how they are related.

Is there any solution or plan to add this feature?

Thanks


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Is-there-a-way-to-autoscroll-the-toc-from-the-content-in-HTML-tp4525.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen