任意Google Swiffy画布大小/屏幕呈现 [英] Arbitrary Google Swiffy Canvas Size / Off Screen Rendering

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

问题描述

我使用Swiffy渲染到一个隐藏的画布上,以便我可以获取结果并在其他地方使用它。我遇到的问题是,当我调整Swiffy的容器div的大小,它不会使实际的画布大于可用的视口大小。如果我设置Swiffy div的尺寸大于视口,那么画布将只会像视口一样大 - 它不想把画布的任何部分移出屏幕。



我确信这是为了效率,没有理由渲染的东西,如果它正常屏幕,但我需要Swiffy渲染它所有的时间,无论我想要什么大小。



此外,Swiffy只是普通拒绝做任何事情,如果Swiffy容器div不附加到DOM。 (强制canvas的宽度和高度为0)。



有没有办法解决这个问题,而不必深入(混淆)Swiffy客户端运行时并修改它?

编辑:我实际上可以让Swiffy渲染大于视口大小?

通过改变window.innerWidth到我想要的。这是一个非常丑的黑客虽然,我讨厌覆盖,因为它导致很多问题。

解决方案

如果你的swiffy运行时版本是7.3,你可以直接攻击js。



只要删除或评论b.xj(c);在g.Tp()函数中。我不在乎屏幕渲染的任何优势。



请注意,它在iframe中很好用,不需要黑客。


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.

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.

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).

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?

Edit: 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.

解决方案

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

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.

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆