本文介绍了任意 Google Swiffy 画布大小/屏幕外渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Swiffy 渲染到隐藏的画布上,以便我可以获取结果并在其他地方使用它.我遇到的问题是,当我为 Swiffy 调整容器 div 的大小时,它不会使实际画布比可用视口大小更大.如果我将 Swiffy div 的尺寸设置为大于视口,那么画布只会变得与视口一样大 - 它不想将画布的任何部分放在屏幕外.

I'm using Swiffy to render onto a hidden canvas so that I can take the result and use it elsewhere. The problem I'm running into is that when I resize the container div for Swiffy it won't make the actual canvas any bigger than the available viewport size. If I set the dimensions of the Swiffy div larger than the viewport then the canvas will only get as big as the viewport - it doesn't want to put any part of the canvas offscreen.

我确定这是为了提高效率,如果它正常在屏幕外,则没有理由渲染某些内容,但我需要让 Swiffy 始终以我想要的任何大小渲染它.

I'm sure this is for efficiency, there's no reason to render something if it's offscreen normally, but I need to have Swiffy render it all the time, at whatever size I want.

此外,如果 Swiffy 容器 div 没有附加到 DOM,Swiffy 只是简单地拒绝做任何事情.(强制画布的宽度和高度为 0).

Additionally, Swiffy just plain refuses to do anything if the Swiffy container div isn't attached to the DOM. (Forces the canvas to have a width and height of 0).

有没有办法解决这个问题,而不必深入研究(混淆的)Swiffy 客户端运行时并修改它?如何欺骗 Swiffy 使其渲染得大于视口大小?

Is there a way around this without having to dig into the (obfuscated) Swiffy client runtime and modify it? How can I trick Swiffy into rendering larger than the viewport size?

我实际上能够通过将 window.innerWidth 更改为我想要的任何内容来欺骗 swiffy 呈现比视口更大的渲染.不过,这是一个非常丑陋的 hack,我不想覆盖它,因为它会导致很多问题.

I was actually able to trick swiffy into rendering larger than the viewport by changing window.innerWidth to whatever I want. That's a really ugly hack though and I hate to overwrite that as it causes a lot of issues.

推荐答案

如果你的 swiffy 运行时版本是 7.3,你可以直接 hack js.

If your swiffy runtime version is 7.3, you can hack the js directly.

只需删除或注释b.xj(c);"在 g.Tp() 函数中.我不在乎屏幕外渲染的任何优势.至少,现在可以用了.

Just remove or comment "b.xj(c);" in g.Tp() function. I don't care any advantage of offscreen rendering. At least, it works now.

我认为这是一个严重的错误.

I think it's a serious bug.

请注意,它在 iframe 中很好,无需 hack.

Note that it's good in iframe, no need to hack.

这篇关于任意 Google Swiffy 画布大小/屏幕外渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:35