-
Notifications
You must be signed in to change notification settings - Fork 85
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
Misalignment of chart profile when preferCanvas: true
on MacOS
#232
Comments
Hi @hupe13, so I guess the solution may be similar / related to: b16c06d In case you feel like doing some debugging, I suggest you to use browserstack local (if you don't already have an account 👉 https://www.browserstack.com/open-source) 👋 Raruto |
leaflet-elevation/src/components/d3.js Line 613 in 8681792
This line must be if(/Mac|iPod|iPhone|iPad/.test(navigator.platform) && /AppleWebkit/i.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) { then Chrome works. In Safari whithout any transformation if(/Mac|iPod|iPhone|iPad/.test(navigator.platform) && /AppleWebkit/i.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) {
//canvas .style("transform", "translate(" + margins.left + "px," + margins.top + "px)");
console.log(canvas);
} I can't get it in the right position. |
You can see the problem on my page. I have an error handler for the problem, it is currently turned off. |
@hupe13 Did you test From what I see it could also be that:
Below you can see how your test-mit-wp.gpx file looks to me if update the Mac OS Ventura + Chrome 110 + leaflet 1.9.3Mac OS Ventura + Safari 16 + leaflet 1.9.3👋 Raruto |
preferCanvas: true
on MacOS
You are right, it is my problem, your example works. It could be that it is related to leaflet-ui, I don't use that. I am looking and will report. Sorry and thank you for you help. |
I have been able to narrow down the problem further but have not yet solved it. Your leaflet-elevation_extended-ui.html has this as well: |
The reason was a css, I don't remember why I configured that. Probably updates from leaflet-elevation made it obsolete. I don't know. But the above problem still exists. And you should change the line 613 (only this line) for Chrome: if(/Mac|iPod|iPhone|iPad/.test(navigator.platform) && /AppleWebkit/i.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) { |
Don't keep me on my toes, i'm a curious guy! Which css rule? 🌵
Ok, I'll let you know when I've done some testing 👋 Raruto |
@hupe13 Am I missing something?, here's how I see it without changing anything in code: |
console.log(navigator.userAgent); Safari logs:
Chrome logs:
leaflet-elevation_extended-ui.html is displayed correctly in Chrome without any changes. My example isn't. I do not know what to do. |
@hupe13 if you are referring to the If you link me again to the page that's giving you trouble, I'll look at it later too. 👋 Raruto |
@hupe13 ref: #232 (comment) My fault, if you look closely at my image there is a horizontal shift in my example too. I'm no expert on the subject but I imagine that by now the chrome developers have fixed the following bug:
Anyway, I think the solution you proposed works correctly on Mac OS Chrome desktop, but it should also be tested on ios (chrome and mobile safari) before proceeding. As for #232 (comment), it seems me to be an issue related only to Safari browsers (if someone sends me a Mac I can also investigate better .. 😋). 👋 Raruto |
I don't have an iPhone also. I do not invest any more time at the moment, with the change of the line 613 and set preferCanvas to false on Safari it works fine on MacOS, and on Chrome also. |
@hupe13 continue here from #257 (comment)
Here's the reason behind this bug
And here's how we might go about fixing it (not perfect, styles ? 🆘): // Attempt to fix: https://bugs.webkit.org/show_bug.cgi?id=201110
function fixingWebkitBug201110({chart, panes, canvas, foreignObject}) {
if (
/Mac|iPod|iPhone|iPad/.test(navigator.platform) &&
/AppleWebkit/i.test(navigator.userAgent) &&
!/Chrome/.test(navigator.userAgent)
) {
panes.tooltip.attr('id', 'webkit-' + Math.random().toFixed(20).slice(2));
canvas.attr('style', canvas.attr('style')+ ';position: absolute; inset: 0; z-index:0;');
foreignObject
.append("svg:svg")
.attr('style', 'position: absolute; inset: 0; width: 100%; height: 100%; z-index:1; stroke: #fff;')
.html('<use href="#' + panes.tooltip.attr('id') + '" style="" />');
}
}
// The following code is needed just to make you able to test it (without changing the source..)
// Hook "fixingWebkitBug201110" into class constructor
L.Control.Elevation.addInitHook(function() {
this.on('elechart_init', function() {
const chart = this._chart._chart;
fixingWebkitBug201110({
chart: chart,
panes: chart.panes,
canvas: chart.utils.canvas,
foreignObject: chart.utils.canvas.select(function() { return this.parentNode; }
});
});
}); 👋 Raruto |
Hi Raruto,
testing the pull request regarding gesture handling, I found out, that a similar SVG issue like this exists on MacOS Chrome 110 and Safari if:
Chrome:
Safari:
(sorry about editing, I forgot to note my relavant setting).
The text was updated successfully, but these errors were encountered: