-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Long TOC scroll selected list element to view when content page is scrolled #114
Comments
Glad to hear Tocbot works for you! I’m currently on vacation and won’t be able to work on this feature, but if you’d like to try and make a pull request I’d be happy to take a look. Thanks for the suggestion! |
I wish I could. Front-end development is far from what I have done most of my life. Could you suggest some tips on how it could be done? If not now, may be later. |
Hey, sorry for the delay in responding. I’ll be back from vacation in 3 weeks and once I’m back I can revisit what it would take to implement this feature. Thanks for the suggestion though. I hope you have a happy start to the new year! |
I've looked into implementing this and the code / complexity required for this feature is substantial. For now I'm going to hold off on this unless more people start asking for it. Thanks for the suggestion though. |
The scroll sync feature for index and content in action - https://coda.io/developers/apis/v1beta1 |
I have implemented a workaround like this, and it seems to work fine:
Wondering @tscanlin if that would be acceptable to integrate this as part of tocbot directly? (just before the |
Since this is an edge case but occasionally comes up, I'd be most open to just adding a util like |
Forgot to add to the snippet this line (the most important! 😅 ), to synchronize the toc with the scroll:
In tocbot, the code would use directly the logic used to detect which area is scrollable and plug into the same callback. Why do you think it would be a problem to integrate it transparently without the user having to plug it himself? Modifying scrolltop for the toc should not change the visual behavior if the jstoc is not scrollable. |
@xoofx Thanks, I can add that to the readme. But I guess I'm hesitant to add it for all cases because it seems like its extra code that shouldn't be needed for 95%+ cases and it could potentially break some layouts. I would probably rather start with this and if there is more demand for it then add it in directly. |
I agree that it's maybe better to not make it default... but, could we add a bool option instead to the existing options and activate it only in that case? That would be straightforward and easier for users, it would not expose the internal (the UpdateVisibleToc) but only an option, what do you think? |
Apologies for the delay on this. I've decided to take your advice @xoofx and offer this as a built-in / default option that only applies when the toc is long and scrolling. What do you think? |
Also, @shashaanktulsyan & @mengjade let me know if this serves your needs or if you have any comments on the PR. |
It looks good. I will try this and let you know. |
Looks good 👍 , let's follow that on the PR directly |
Hi,
![image](https://user-images.githubusercontent.com/6197269/50457446-94007580-0981-11e9-9cd6-144d242084ff.png)
Thank you for your amazing plugin. I was able to get exactly what I wanted with minimal effort. The initialization API is precise, concise with enough options. This what I was able to get.
This is a screenshot of a page of work in progress website, which will be documenting Hindu history.
Each webpage is like a chapter, and sometimes like a book, which if printed as a pdf can be anywhere between 30 to 300 pages.
So naturally when I make the TOC, it has several elements, and thus it needs a scrollbar.
That little bit I was able to manage, without much of an issue.
Everything looks fine, except, one thing.
As I scroll the page down further, eventually the highlighted/selected region of the document, is so far away from the top, that it is not visible in the TOC unless the TOC itself is scrolled. This I am doing manually. It would be great if it can be automated.
So when a scroll event is fired, which basically hides/unhides list-elements in the TOC, it should also do something like a scrollIntoView for the TOC, so that the TOC's scroll keeps pace with the actual document.
May be a flag in the api would be nice to have. Apart from this, TOCBOT is just perfect for what I needed.
The text was updated successfully, but these errors were encountered: