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.
The only way I could figure out how to do it is to edit the Swiffy runtime and replace all instances of window.innerWidth and window.innerHeight with whatever size I wanted.
No ill side affects that I could see, though this is obliviously less than ideal.
If someone comes up with a better solution I'll absolutely accept it.
If i get the problem correctly, for rendering larger than the original swiffy you can put swiffy in a div and scale it
To have swiffy restrict to its original output scale as from flash, you can place it in an iframe
来源:https://stackoverflow.com/questions/31568985/arbitrary-google-swiffy-canvas-size-off-screen-rendering