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

fix(svg): svg mouse event doesn't work normally in Firefox when using shadow. #812

Merged
merged 2 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ export function clientToLocal(
// <https://bugs.jquery.com/ticket/8523#comment:14>
// BTW3, In ff, offsetX/offsetY is always 0.
else if (env.browser.firefox
// use offsetX/offsetY for Firefox >= 39
// PENDING: consider Firefox for Android and Firefox OS? >= 43
&& env.browser.version < '39'
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose '39' should be a number here?

Copy link
Collaborator Author

@plainheart plainheart Sep 10, 2021

Choose a reason for hiding this comment

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

I'm not sure if the version string in some earlier versions will probably be like 88.0.1, though I saw the version string in the navigator.userAgent is like 88.0 in most of the versions. (Tested it in Firefox 50, 70, 80, 92)

UA FULL VERSION

UPDATE

After reading these two threads, I guess it may be by design. So it should be okay if we change to use number 39.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. Seems string comparison is better. Let's keep it.

&& (e as FirefoxMouseEvent).layerX != null
&& (e as FirefoxMouseEvent).layerX !== (e as MouseEvent).offsetX
) {
out.zrX = (e as FirefoxMouseEvent).layerX;
out.zrY = (e as FirefoxMouseEvent).layerY;
}
// For IE6+, chrome, safari, opera. (When will ff support offsetX?)
// For IE6+, chrome, safari, opera, firefox >= 39
else if ((e as MouseEvent).offsetX != null) {
out.zrX = (e as MouseEvent).offsetX;
out.zrY = (e as MouseEvent).offsetY;
Expand Down
4 changes: 2 additions & 2 deletions src/svg/helper/ShadowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class ShadowManager extends Definable {
remove(svgElement: SVGElement, displayable: Displayable) {
if ((displayable as DisplayableExtended)._shadowDom != null) {
(displayable as DisplayableExtended)._shadowDom = null;
svgElement.style.filter = '';
svgElement.removeAttribute('filter');
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ export default class ShadowManager extends Definable {
(displayable as DisplayableExtended)._shadowDom = shadowDom;

const id = shadowDom.getAttribute('id');
svgElement.style.filter = 'url(#' + id + ')';
svgElement.setAttribute('filter', 'url(#' + id + ')');
}

removeUnused() {
Expand Down