Handle positioning to a hash URL when the link is to an element within SVG output. Resolves remainder of issue #297.
This commit is contained in:
parent
b58c667f8b
commit
a30d9067fe
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@ if (!window.MathJax) {window.MathJax= {}}
|
|||
if (!MathJax.Hub) { // skip if already loaded
|
||||
|
||||
MathJax.version = "2.0";
|
||||
MathJax.fileversion = "2.0.5";
|
||||
MathJax.fileversion = "2.0.6";
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
|
@ -1923,9 +1923,22 @@ MathJax.Hub.Startup = {
|
|||
for (var i = 0, m = a.length; i < m; i++)
|
||||
{if (a[i].name === name) {target = a[i]; break}}
|
||||
}
|
||||
if (target) {setTimeout(function () {target.scrollIntoView(true)},1)}
|
||||
if (target) {
|
||||
while (!target.scrollIntoView) {target = target.parentNode}
|
||||
target = this.HashCheck(target);
|
||||
if (target && target.scrollIntoView)
|
||||
{setTimeout(function () {target.scrollIntoView(true)},1)}
|
||||
}
|
||||
}
|
||||
},
|
||||
HashCheck: function (target) {
|
||||
if (target.isMathJax) {
|
||||
var jax = MathJax.Hub.getJaxFor(target);
|
||||
if (jax && MathJax.OutputJax[jax.outputJax].hashCheck)
|
||||
{target = MathJax.OutputJax[jax.outputJax].hashCheck(target)}
|
||||
}
|
||||
return target;
|
||||
},
|
||||
|
||||
//
|
||||
// Load the Menu and Zoom code, if it hasn't already been loaded.
|
||||
|
|
|
@ -345,6 +345,16 @@
|
|||
state.SVGlast = state.SVGeqn;
|
||||
},
|
||||
|
||||
//
|
||||
// Return the containing HTML element rather than the SVG element, since
|
||||
// most browsers can't position to an SVG element properly.
|
||||
//
|
||||
hashCheck: function (target) {
|
||||
if (target && target.nodeName === "g")
|
||||
{do {target = target.parentNode} while (target && target.firstChild.nodeName !== "svg")}
|
||||
return target;
|
||||
},
|
||||
|
||||
getJaxFromMath: function (math) {
|
||||
if (math.parentNode.className === "MathJax_SVG_Display") {math = math.parentNode}
|
||||
return HUB.getJaxFor(math.nextSibling);
|
||||
|
@ -1035,12 +1045,9 @@
|
|||
SVGlink: function () {
|
||||
var href = this.href.animVal;
|
||||
if (href.charAt(0) === "#") {
|
||||
var link = document.getElementById(href.substr(1));
|
||||
if (link && link.nodeName === "g") {
|
||||
do {link = link.parentNode} while (link && link.nodeName !== "svg");
|
||||
if (link && link.parentNode && link.parentNode.scrollIntoView)
|
||||
{setTimeout(function () {link.parentNode.scrollIntoView(true)},1)}
|
||||
}
|
||||
var target = SVG.hashCheck(document.getElementById(href.substr(1)));
|
||||
if (target && target.scrollIntoView)
|
||||
{setTimeout(function () {target.parentNode.scrollIntoView(true)},1)}
|
||||
}
|
||||
document.location = href;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user