Comments (13)
I have tested with 3.0.2 and 3.0.5 in offline documents and confirm this still exists in 3.0.5.
from tocbot.
Hey, thanks for reporting this @danyill! I have a fix for it here:
#69
Really appreciate the detailed report 👍
from tocbot.
Fixed in 3.0.6
.
from tocbot.
Thank you so much for such a magically speedy response. I confirm this corrects this issue in both browsers mentioned above.
Alas, that only brings me to my next problem which I think may be related (it may be better in another issue, but I think it is intimately related to the same code).
In my application I have a rather long table of contents in a sidebar (based on the Asciidoctor default stylesheet). I have set the collapseDepth
to 6
because the feature of tocbot that I want (for now) is for the table of contents to highlight the entry the user is on.
Because the table of contents in the sidebar scrolls beneath the screen, I seek to relocate the sidebar position (vertically) to always be showing a bit before and a bit after the present TOC entry.
To achieve this, I use the following:
scrollEndCallback: function (e) {
console.log('hi');
document.getElementsByClassName('is-active-link')[0].scrollTop += 100;
document.getElementsByClassName('is-active-link')[0].scrollIntoView({ behavior: 'smooth' });
},
This works delightfully in Chrome (version above). With the code above, as I scroll I get console log entries caused by the scrollEndCallback
.
In both IE and Edge I get no log entries, implying that the scrollEndCallback
is never called.
from tocbot.
I'm sorry to hear you are still having trouble with this, but I'll try to help. However, I am unable to reproduce the issue, it works fine for me. Can you provide a test case or example of the scrollEndCallback
failing to be called?
from tocbot.
Thank you for your kind offer of help.
This rather long gist contains tocbot 3.0.6 embedded (so ignore the missing resource for tocbot and many other things) and should be a reasonable representative use case if not a concise example (I mainly produce offline documentation with some imperfections in the way resource loading occurs due to toolchain constraints)
On line 2428
I have:
scrollEndCallback: function (e) { document.getElementsByClassName('is-active-link')[0].scrollTop += 100; tocbot.refresh(); console.log('hi i am a scrollback'); document.getElementsByClassName('is-active-link')[0].scrollIntoView({ behavior: 'smooth' }); }
By the time I've scrolled top to bottom in Chrome I have:
In Edge / IE I have nothing. It makes no difference if I reduced the callback to only the console.log
statement.
from tocbot.
I tried to load it up but didn't see any console.log in chrome.. Can you host this example somewhere?
I tried your callback and it worked fine for me in chrome and IE. But maybe tocbot doesn't like really long content. Does the highlighting still work? Maybe its adjusting the scroll position in the callback thats causing issues. You could try wrapping that in a setTimeout. Hope that helps.
from tocbot.
The highlighting does still work. The gist I think is too big to update in the online editor so when I added the console.log I think it failed to save.
Zip file with html inside attached.
from tocbot.
It appears you are still running with the older version. (e&&0===e.eventPhase||t)
The new code should contain 0===e.eventPhase||null===e.currentTarget
See: https://raw.githubusercontent.com/tscanlin/tocbot/master/dist/tocbot.min.js
Hope that fixes it.
from tocbot.
from tocbot.
Yeah, it appears it didn't publish properly. I just published 3.0.7
which should solve the issue.
from tocbot.
Thank you.
I confirm that 3.0.7
is correct and scrollback now works more or less nicely (the scrollTop doesn't quite work in IE and Edge but it does at least track the TOC in the sidebar with the main document).
Have a good weekend 😄
from tocbot.
Great, glad to hear that! :)
You have a good weekend too.
from tocbot.
Related Issues (20)
- Navigation don't scroll to position with cyrillic characters ids HOT 6
- Regarding the description of the options, it is recommended to update HOT 15
- Help with large HTML, strange TocBot behaviour HOT 11
- Unusual issue with .is-active-link when there are multiple tocbots on a page HOT 1
- Overscroll support HOT 3
- the icon should stay original position when toc unfold HOT 6
- is-active-li not set on scroll or click, only on page load HOT 5
- can't work on hexo-theme-landscape HOT 6
- tocbot 4.18.2 is not detecting h3 HOT 3
- How to scroll the page to a title of an article and highlight a title in the directory HOT 1
- skipRendering true throws exception HOT 2
- Using `headingObjectCallback` doesn't modify ID with `createLink`? HOT 3
- hasInnerContainers: false is not working for relative and abosulte container HOT 3
- Can add support collapsed / collapsible callback ? HOT 1
- Feature: Transform to dropdown on mobile HOT 1
- Feature Request: optionally let TocScrollSync only enabled when the active header is not shown HOT 4
- index.d.ts mismatch current options HOT 2
- No highlight in Hugo Dream template HOT 2
- How can I add an extra nav link for example "Comments"? HOT 3
- headingsOffset does not work with scrollSmooth: true HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tocbot.