Skip to content

Commit

Permalink
Merge pull request #615 from mathjax/issue2530
Browse files Browse the repository at this point in the history
Make sure hitbox is translated along with the hit-able element. (mathjax/MathJax#2530)
  • Loading branch information
dpvc authored Mar 8, 2021
2 parents cc5ba3a + 310f046 commit 6b98ce7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ts/output/svg/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,19 @@ CommonWrapper<
*/
public place(x: number, y: number, element: N = null) {
if (!(x || y)) return;
const adaptor = this.adaptor;
const translate = 'translate(' + this.fixed(x) + ', ' + this.fixed(y) + ')';
if (!element) {
element = this.element;
if (this.node.attributes.get('href')) {
const rect = adaptor.previous(element);
if (rect && adaptor.kind(rect) === 'rect' && adaptor.getAttribute(rect, 'data-hitbox')) {
adaptor.setAttribute(rect, 'transform', translate);
}
}
}
let transform = this.adaptor.getAttribute(element, 'transform') || '';
transform = 'translate(' + this.fixed(x) + ', ' + this.fixed(y) + ')' + (transform ? ' ' + transform : '');
this.adaptor.setAttribute(element, 'transform', transform);
let transform = adaptor.getAttribute(element, 'transform') || '';
adaptor.setAttribute(element, 'transform', translate + (transform ? ' ' + transform : ''));
}

/**
Expand Down

0 comments on commit 6b98ce7

Please sign in to comment.