画布仅在iPhone上水平显示

发布于 2025-02-13 22:15:20 字数 952 浏览 0 评论 0原文

我正在为此失去理智...我正在从事一个不错的个人项目,并且我有一个画布,我在上面绘制了一些图表...问题是,即使在iPhone上,帆布都可以正常工作但是,只有当它是水平的...有人对发生的事情有任何想法吗?

HTML是这样的:

<html>
  <body>
   <canvas></canvas>
  </body>
</html>

使用JS使用JS设置了帆布大小:

const canvas = document.querySelector("canvas");
const c = canvas.getContext('2d');
canvas.width = window.innerWidth * canvasScale;
canvas.height = window.innerHeight * canvasScale;
canvas.style.width = window.innerWidth+"px";
canvas.style.height = window.innerHeight+"px";

我是否缺少某些内容?

如果要检查整个代码,该项目将在此处上传:
https://htmlpreview.github.io/?https://github.com/albertosinigaglia/force-graph/blob/blob/main/main/force-graph-optimization.html

I'm losing my mind on this... I'm working on a nice personal project, and I have a canvas on which I paint some graph... How, the issue is that that canvas works everywhere, even on IPhone, but only if it's horizontal... has anybody an Idea on what's going on?

the HTML is something like this:

<html>
  <body>
   <canvas></canvas>
  </body>
</html>

and the canvas size are set using JS with the following script:

const canvas = document.querySelector("canvas");
const c = canvas.getContext('2d');
canvas.width = window.innerWidth * canvasScale;
canvas.height = window.innerHeight * canvasScale;
canvas.style.width = window.innerWidth+"px";
canvas.style.height = window.innerHeight+"px";

am I missing something?

The project is uploaded here if you want to check the whole code:
https://htmlpreview.github.io/?https://github.com/AlbertoSinigaglia/force-graph/blob/main/force-graph-optimization.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文