Skip to content
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

Update SVG output so that following a link scrolls to the top of the tag. (mathjax/MathJax#2588) #670

Merged
merged 2 commits into from
Apr 14, 2021

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Mar 29, 2021

In Firefox, following a link in SVG output would scroll to the bottom of the linked content rather than the top. In Safari, that would occur if the linked content was a <text> node, like from a \tag with mtextInheritFont: true. This PR adjusts the output of elements with ID so that Firefox and Safari (and Chrome) all scroll to the top of the linked content.

That required shifting the element with the ID upward by its height, and then shifting its contents down by the sea amount (so that it is in the correct visual location, but the element's location for linking purposes is the top of the content. A <text> element is also added so that Safari will scroll to the right location.

Since this required putting some unexpected elements as the children of the node with the id attribute, a new firstChild() method was added that skips over the unexpected nodes. That also allows moving the rect that was used as the hotbox for an href to also be put inside the element with the href rather than just before it, as in the past. (This corresponds to Peter's suggestion in mathjax/MathJax#2530.) The firstChild() method skips the href element as well.

Resolves mathjax/MathJax#2588.

@dpvc dpvc added this to the 3.1.3 milestone Mar 29, 2021
@dpvc dpvc requested a review from zorkow March 29, 2021 21:11
Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As my Mac is too decrepit, I could not check the issue/solution in Safari.
Firefox seems to work fine.

Base automatically changed from issue2601 to develop April 14, 2021 13:53
@dpvc dpvc merged commit 75fb8c6 into develop Apr 14, 2021
@dpvc dpvc deleted the issue2588 branch April 14, 2021 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants